W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2002

Re: validating soap requests

From: <noah_mendelsohn@us.ibm.com>
Date: Fri, 27 Dec 2002 10:37:11 -0500
To: Antňnia Galmés <a.galmes@barcelo.com> (by way of "C. M. Sperberg-McQueen" <<a.galmes@barcelo.com<a.galmes>)
Cc: www-xml-schema-comments@w3.org
Message-ID: <OF373DA7BE.55E03A25-ON85256C9C.0053BE7B@lotus.com>
Antňnia Galmés writes:

> Hi!
> I have a problem writing an schema. We have developed a
> XML interface that accepts the requests to our system
> using SOAP (but it's use is optional).  The xml
> requests are grouped with the tag
> <requests_set>... </requests_set> and may be more than
> one. The request as a whole would be:
> <?xml version="1.0" encoding="UTF-8" ?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <SOAP-ENV:Body>
>      <requests_set>
>          <request1>
>              ...
>          </request1>
>               .
>               .
>               .
>      </requests_set>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> I have written an schema to validate the incoming
> requests, starting from the complex type
> "requests_set". The validation is ok if I don't write
> the outer SOAP tags, but I get a validating error when
> the requests come into the soap-env:body tag because
> this does not appear in my schema. The problem is that
> I don't know how to include the soap elements in the
> schema I've written. Now, the schema is starting like
> this:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" >
>      <xsd:element name="requests_set" type="aux_type"/>
>      <xsd:complexType name="aux_type">
>          <xsd:sequence>
>              <xsd:element name="request1" type="t1" minOccurs="0"
> maxOccurs="unbounded"/>
>              <xsd:element name="request2" type="t2" minOccurs="0"
> maxOccurs="unbounded"/> etc.
> How do I indicate that the "requests_set" may be in a
> SOAP block?
> Thank you in advance. 

This is mostly a question about XML schema, of course, not SOAP.  The 
fundamental answer is that the XML schema recommendation anticipates such 
needs in a variety of ways >>but you have to get a schema validator that 
meets your needs<<.  What the schema recommendation says essentially is: 
according to the needs of an application, processors MAY allow validity 
assessment to begin with any element in the instance, and using any 
complexType definition or element declaration.  Now, processors don't have 
to allow such great flexibility, but they're allowed to. 

So, the question is, what does the processor you're using do, and what 
might others do?  Most processors out there are aimed at the obvious 
"validate the whole document based on the declaration of the root element 
scenario."  I'm honestly not sure which ones if any allow you a finer 
degree of control, but in principle it's allowed.

There is another technique that is often used to solve this problem.  If 
you look at the schema for SOAP at [2] it contains:

<xs:complexType name="Body">

    <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" 
processContents="lax" /> 

  <xs:anyAttribute namespace="##any" processContents="lax">
         Prose in the spec does not specify that 
         attributes are allowed on the Body element

If you note the processContents="lax", that means that the schema processor will validate the body if and only 
if an element declaration is provided for the particular body element 
child you provide.  In your case, this is "requests_set".  So, if you 
provide a schema processor with both the schema for the SOAP envelope and 
for your schema for requests_set, which are presumably in separate schema 
documents, then the validation should occur.  Exactly how to provide such 
multiple documents, if it's possible at all, depends on the API or command 
line options to the processor you are using. 

One other suggestion: it's really better practice to use namespace 
qualification on elements like "requests_set".  That will help your SOAP 
message stand out from any others that might use an otherwise similar 
element name.

I hope this is helpful to you. 


[1] http://www.w3.org/TR/xmlschema-1/#validation_outcome
[2] http://schemas.xmlsoap.org/soap/envelope/ 

Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
Received on Friday, 27 December 2002 10:41:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:08:59 UTC