XML Schema Validation: SOAP Issue / Namespace Issue

I am trying to get XML validation working for a SOAP server but I've run into a couple of issues.

XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://p2p.thalesgroup.com/wsdl/status/xsd"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  attributeFormDefault="qualified"
  targetNamespace="http://p2p.thalesgroup.com/wsdl/status/xsd">
 
  <xsd:element name="Alive">
    <xsd:complexType>
      <xsd:annotation>
        <xsd:documentation>
          - Alive is sent periodically to verify the connection status
        </xsd:documentation>
      </xsd:annotation>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Open in new window


XML:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body><Alive/></soap:Body>
</soap:Envelope>

Open in new window


First Issue:
SOAP elements are not being recognized.
Validator Output: Cannot Find The Declaration Of Element 'soap:Envelope'., Line '1', Column '225'.
I found a Stack Overflow thread describing the same issue but the described solutions do not work for me.

Second Issue:
Even if I remove the SOAP elements, I still have a namespace issue.
Validator Output: Cannot Find The Declaration Of Element 'Event'., Line '1', Column '8'.
LVL 1
bejhanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
I am trying to get XML validation working

What are you trying to validate it with? What is actually performing the validation?

The problem is that it doesn't seem to be locating your XSD at all.
0
bejhanAuthor Commented:
I'm passing the full XSD to a validator. I've tried QXMLSchemaValidator programatically and also an online tool manually, to the same result.
0
bejhanAuthor Commented:
I changed my examples to simplify the question but the same problems remain.

I solved the second issue by removing a non-existent namespace URL from the XSD file:
targetNamespace="http://p2p.thalesgroup.com/wsdl/status/xsd"

Open in new window


Still grappling with the first issue.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

bejhanAuthor Commented:
I solved the first issue by importing not just the namespace but also the schema:
<xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>

Open in new window

0
bejhanAuthor Commented:
Just to clarify, for anyone reading this in the future, the problem with the targetNamespace was not that it didn't exist.
After some more research, I realized that namespace URLs aren't actually resolved. Rather, they just serve as unique identifiers.
Why URLs were chosen is beyond me. This just added to my initial confusion.

The problem was actually that my XML file did not declare the namespace indicated by targetNamespace so the XML file and XSD file were not in agreement.
Removing the targetNamespace fixed the issue because doing so put the XSD in the global namespace, with which the XML file was dealing (since it didn't specify a namespace).

This could've instead been solved by setting the same namespace in the XML file.
<Alive xmlns="http://p2p.thalesgroup.com/wsdl/status/xsd"/>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bejhanAuthor Commented:
Another clarification, for anyone reading this in the future, importing the SOAP namespace and schema does not have the exact desired effect because the SOAP schema specifies lax validation for its body contents.

This means that:
- DESIRED: If a tag declared in my schema exists, it will be validated according to our a schema.
- UNDESIRED: If a tag not declared in my schema exists, it will pass validation.
- UNDESIRED: If the body is empty, it will pass validation.

My solution was download the SOAP schema and modify it to have strict validation for its body contents
0
bejhanAuthor Commented:
I solved my own question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.