| | |
SOAP n00b
Please support our RSS, Web Services and SOAP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
•
•
Join Date: Jul 2006
Posts: 132
Reputation:
Solved Threads: 0
Hi,
I trying to learn SOAP from http://www.w3schools.com . The tutorials are not bad but I still have some questions.
1) What EXACTLY is the purpose of namespaces?
2) Why use multiple namespaces? Why is there
a m: namespace in the code?
3) Do I have to create the uri m: refers to?
I do not know if my questions make sense.
But any help would be appreciated. Thanks in advance.
I trying to learn SOAP from http://www.w3schools.com . The tutorials are not bad but I still have some questions.
RSS, Web Services and SOAP Syntax (Toggle Plain Text)
<?xml version="1.0"?> <soap:Envelope xmlns:soap="<a rel="nofollow" class="t" href="http://www.w3.org/2001/12/soap-envelope" target="_blank"> http://www.w3.org/2001/12/soap-envelope</a> " soap:encodingStyle="<a rel="nofollow" class="t" href="http://www.w3.org/2001/12/soap-encoding" target="_blank"> http://www.w3.org/2001/12/soap-encoding</a> "> <soap:Body> <m:GetPrice xmlns:m="<a rel="nofollow" class="t" href="http://www.w3schools.com/prices" target="_blank">http://www.w3schools.com/prices</a>"> <m:Item>Apples</m:Item> </m:GetPrice> </soap:Body> </soap:Envelope>
2) Why use multiple namespaces? Why is there
a m: namespace in the code?
3) Do I have to create the uri m: refers to?
I do not know if my questions make sense.
But any help would be appreciated. Thanks in advance.
Namespaces are a way to separate or class the elements in a document that is composed of elements from multiple schema (different types of XML file)
You don't have to create schema documents; in essence a schema document (like the one at http://www.w3.org/2001/12/soap-envelope) just defines which elements can have which attributes/children. They do not define processing rules very thoroughly, and at the moment, can only really be seen as a strict 'template' definition for a nodeset representing the namespace.
Exactly "how" a processor interprets a namespace seems to be quite an arbitrary thing; most XML technology processors perform set tasks based on document structure/order, and perhaps only interpret namespaces by looking at a list of which URI schemas relate to their specific task(s). A good (but probably slow) parser for a technology could in theory, download the namespace schema and use it to validate the elements within its namespace. A developer could probably take that further by reading 'lookups'/references from the schema and using them programatically within a parser's processing job to control the parser's activity.
In theory; a good SOAP parser should be able to understand:
In practise, only new &conformant parsers would be able to deal with this. Some parsers may only respond (in a defined way) to elements that start with their prefered namespace regardless of where the namespace is sourced from via an xmlns attribute.
You don't have to create schema documents; in essence a schema document (like the one at http://www.w3.org/2001/12/soap-envelope) just defines which elements can have which attributes/children. They do not define processing rules very thoroughly, and at the moment, can only really be seen as a strict 'template' definition for a nodeset representing the namespace.
Exactly "how" a processor interprets a namespace seems to be quite an arbitrary thing; most XML technology processors perform set tasks based on document structure/order, and perhaps only interpret namespaces by looking at a list of which URI schemas relate to their specific task(s). A good (but probably slow) parser for a technology could in theory, download the namespace schema and use it to validate the elements within its namespace. A developer could probably take that further by reading 'lookups'/references from the schema and using them programatically within a parser's processing job to control the parser's activity.
In theory; a good SOAP parser should be able to understand:
RSS, Web Services and SOAP Syntax (Toggle Plain Text)
<?xml version="1.0"?> <soapy:Envelope xmlns:soapy="http://www.w3.org/2001/12/soap-envelope" soapy:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soapy:Body> <m:GetPrice xmlns:m="http://www.w3schools.com/prices"> <m:Item>Apples</m:Item> </m:GetPrice> </soapy:Body> </soapy:Envelope>
In practise, only new &conformant parsers would be able to deal with this. Some parsers may only respond (in a defined way) to elements that start with their prefered namespace regardless of where the namespace is sourced from via an xmlns attribute.
Plato forgot the nullahedron..
The 'm' namespace by the way; has just been used as an example in that document. You'll see that there is no schema document at that location; wheras for the SOAP namespace; there is one (use View Source in your browser to see it).
You can always use the default namespace (element's with no prefix: part) if you're mixing a single custom schema with a 'technology' schema (like SOAP or XSLT),
In XHTML documents, the default namespace is usually set to the XHTML namespace... I suppose you should define the default namespace in the root node of any document.
Providing the <GetPrice> node is always going to be the root node; this would be correct:
BUT! for the most part; not defining the default namespace is usually OK. Especially if you don't know where that node is going to end up within a larger document.
You can always use the default namespace (element's with no prefix: part) if you're mixing a single custom schema with a 'technology' schema (like SOAP or XSLT),
In XHTML documents, the default namespace is usually set to the XHTML namespace... I suppose you should define the default namespace in the root node of any document.
Providing the <GetPrice> node is always going to be the root node; this would be correct:
RSS, Web Services and SOAP Syntax (Toggle Plain Text)
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body> <GetPrice xmlns="http://www.w3schools.com/prices"> <Item>Apples</Item> </GetPrice> </soap:Body> </soap:Envelope>
BUT! for the most part; not defining the default namespace is usually OK. Especially if you don't know where that node is going to end up within a larger document.
Plato forgot the nullahedron..
•
•
Join Date: Jul 2006
Posts: 132
Reputation:
Solved Threads: 0
First of all thanks for replying to my post. So if I understand you correctly,
<a: node1>
...........
<b:node2>
.........
</node2>
<node1>
node1 will follow the rules described by page a. Where as node2 will follow rules from page b.
And the purpose of the m: before <getPrices> is to make sure that only the <Item> node can be placed inside the <getPrice> node. Am I getting this right?
<a: node1>
...........
<b:node2>
.........
</node2>
<node1>
node1 will follow the rules described by page a. Where as node2 will follow rules from page b.
And the purpose of the m: before <getPrices> is to make sure that only the <Item> node can be placed inside the <getPrice> node. Am I getting this right?
•
•
•
•
First of all thanks for replying to my post. So if I understand you correctly,
<a: node1>
...........
<b:node2>
.........
</a:node2>
<b:node1>
node1 will follow the rules described by page a. Where as node2 will follow rules from page b.
It's more important that the namespaces separate the two types of data in that document, and that namespaces generally (although not officially) imply that a group of nodes could be processed by a different technology than other nodes in the document.
•
•
•
•
And the purpose of the m: before <getPrices> is to make sure that only the <Item> node can be placed inside the <getPrice> node. Am I getting this right?
SOAP perhaps uses namespaces more than other technologies, because there seem to be alot of technologies that can be used within a single SOAP document.
Perhaps this document will be more helpful than me with regard to SOAP specifically:
http://www.awprofessional.com/articl...&seqNum=2&rl=1
Plato forgot the nullahedron..
You're getting closer certainly; and from a parser's perspective that's pretty much exactly how a namespace works.
From a developers perspective, although the namespace does visually separate those nodes from the surrounding document, it's more that we're highlighting those nodes as being a specific grouping so that a parser could decide to treat them differently to how it may treat nodes in another (different) namespace.
From a developers perspective, although the namespace does visually separate those nodes from the surrounding document, it's more that we're highlighting those nodes as being a specific grouping so that a parser could decide to treat them differently to how it may treat nodes in another (different) namespace.
Plato forgot the nullahedron..
•
•
•
•
I plan on learning to build web services using java. Can you tell me what softwares I need? Is the regular jdk 1.6.0 that I have installed sufficient? Or do I need a different version?
•
•
•
•
By the way I am trying follow instruction from a book and tomcat is installed twice in the book's example. First its installed in the home folder as a servlet !container! and then its installed in the /usr/local/ folder as a web server. Is this a typo? Should I follow these directions?
For the first one; it depends what kind of web application you're developing. You have the standard JDK which is fine for web-deployed desktop applications but not ideal because you need to create client-server pairs and/or get past security rules, You have the mobile device JDK (J2ME) which will probably be very web-orientated these days, and things like JSP for 'webpage applications' which you're probably considering if you want to use Tomcat...
For the second one; I imagine that the installation in a home directory is for a modifiable folder, and the installation in the /usr/ folder is for program binaries. Don't take that as an authoritative answer though... I haven't ever used JSP or Tomcat; I'm sure someone who has will be more helpful; and there's a large chance there'll be more of them watching the Java forum than the XML forum.
=)
Plato forgot the nullahedron..
![]() |
Other Threads in the RSS, Web Services and SOAP Forum
- Previous Thread: Mouse events, xml values and Javascript
- Next Thread: RSS to Podcast
| Thread Tools | Search this Thread |
.htaccess 301 accept alltop api authentication binarysecuritytoken blog card city collaboration country credit data development ebay email evernote flash google government highrise htaccess intel internet ip legal live location patent paypal php podcast proxy redirect rss rssfeeds searchmonkey server soap software swappingxmlfromflash swappingxmlnodes url web webservices webservicesecurity wiki wikipedia xml xslt y!os yahoo ydn






