aspose file tools*
The moose likes Web Services and the fly likes SOAP schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAP schema " Watch "SOAP schema " New topic
Author

SOAP schema

Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 217

Hi all,
In the SOAP standard,I could see the declaration of global attributes 'actor' and 'mustUnderstand' but could not notice any references to them in the entire schema document.How could we use them in the header block elements then?

Any thoughful reply would be helpful.

Thanks.....
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 313

Sudhanshu Mishra wrote:Hi all,
In the SOAP standard,I could see the declaration of global attributes 'actor' and 'mustUnderstand' but could not notice any references to them in the entire schema document.How could we use them in the header block elements then?

Any thoughful reply would be helpful.

Thanks.....


If you have gone through the soap envelope schema (http://schemas.xmlsoap.org/soap/envelope/), then you must have noted that for complex types defined in the schema (for eg: envelope, header),
we have defined



The snippet of schema defining header and envelope is:-



It means that you can use any attribute with any element of type header. In other words, the <anyAttribute> element enables us to extend the XML document with attributes not specified with the complex type definition. The attributes can be defined elsewhere in the same schema or can be a part of a different schema altogether. If the type and attribute definitions are part of different xsd files or schemas in the same file, then you would have to specify the schema location for both of them.


Palak Mathur | My Blog | TechJaunt | What is JavaRanch? | List of All FAQs
Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 217

Thanks for the reply,
But still I want to ask that the <anyAttributes> are used for the body and header elements ,but what about the header element's children,and what if they come from a schema which does not permits the use of actor and mustUnderstand attributes?

<anyAtttributes> is used with children of Header element right?

Clarifications please.

Thanks......
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 313

Sudhanshu Mishra wrote:Thanks for the reply,
But still I want to ask that the <anyAttributes> are used for the body and header elements ,but what about the header element's children,and what if they come from a schema which does not permits the use of actor and mustUnderstand attributes?

<anyAtttributes> is used with children of Header element right?

Clarifications please.

Thanks......


Cite an example. Just for your info



means you can put anything as the child of Header/Body
Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 217

Hi Palak and thanks for your replies,
but please have a look at the snippets below

I have two schema files SOAP.xsd and myNamespace.xsd ,and a single xml file using them both.

SOAP.xsd



myNamespace.xsd




SOAP.xml


Now,myNamespace schema won't allow use of any attribute with root element,SOAP schema defines that header element can have any element as its child,and can have any attribute,same for body.
The SOAP.xsd file contains snippets from the standard SOAP.xsd file regarding rules for envelope,body and header element.

Now,If I try to use attribute actor or mustUnderstnad with root in xml file,it gives error(in eclipse editor)Error is "cvc-complex-type.3.2.2: Attribute 'soap:actor' is not allowed to appear in element 'myns:root'.".Why?
The standard SOAP schema is defined in similar manner,but there we are able to declare any attribute for the children of header and body.In above case,I can declare any number of attributes for header and body,but not for their children(element root in this case).
I hope i have made my question clear.
Please be patient with me.

Thanks....
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 313

Few things:-

1. In myNamespace.xsd, when you are defining the complex type "type", you have not defined the attribute that can be used. And you are trying to use an attribute.

Even if you change the xml file




even then your xml will be invalid. To make your xml valid, you should modify the myNamespace.xsd as follows:-



2. When you use mustUnderstand attribute as defined in the soap.xsd, make sure that you use a boolean value. Otherwise, even if all things are in place, your xml will not compile.
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 313

I would recommend that you goo through the Specification for XML Schema. The link is given below:-

http://www.w3.org/XML/Schema#dev
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SOAP schema