What is the difference between the following pieces of xml?
The reason I ask is that when I submit the xml to a BPEL process the first and second one work but the last one does not, what is going on?
<!-- imported namespace referenced with prefix -->
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fxd="http://aaa.yy.zz/Foo">
<soap:Body>
<fxd:GSR>
<aaa>
<a>1000000</a>
<c>UUU</c>
<cp>ZZ</cp>
</aaa>
<bbb>
<cc>CCC</cc>
<v>110005632501</v>
</bbb>
<adate>2009-11-04T07:14:44.5814828+02:00</adate>
<bdate>2009-11-04T07:14:44.5814828+02:00</bdate>
<m>NNNN</m>
<p>SSSS</p>
<r>LLLL</r>
</fxd:GSR>
</soap:Body>
</soap:Envelope>
<!-- inline imported namespace referenced with a prefix-->
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<fxd:GSR xmlns:fxd="http://aaa.yy.zz/Foo">
<aaa>
<a>1000000</a>
<c>UUU</c>
<cp>ZZ</cp>
</aaa>
<bbb>
<cc>CCC</cc>
<v>110005632501</v>
</bbb>
<adate>2009-11-04T07:14:44.5814828+02:00</adate>
<bdate>2009-11-04T07:14:44.5814828+02:00</bdate>
<m>NNNN</m>
<p>SSSS</p>
<r>LLLL</r>
</fxd:GSR>
</soap:Body>
</soap:Envelope>
<!-- inline namespace -->
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GSR xmlns="http://aaa.yy.zz/Foo">
<aaa>
<a>1000000</a>
<c>UUU</c>
<cp>ZZ</cp>
</aaa>
<bbb>
<cc>CCC</cc>
<v>110005632501</v>
</bbb>
<adate>2009-11-04T07:14:44.5814828+02:00</adate>
<bdate>2009-11-04T07:14:44.5814828+02:00</bdate>
<m>NNNN</m>
<p>SSSS</p>
<r>LLLL</r>
</GSR>
</soap:Body>
</soap:Envelope>
My intuition says they are equivalent pieces of xml, especially considering they come from the same wsdl. They are parsed successfully but the namespaces of the elements are not what they should be.
They are not equal. That is, example 1 and 2 are equal, but 3 is not.
Look at
<fxd:GSR>in contrast to<GSR>. You see, that the first one is prefixed. Now, if you define a namespacexmlns:fxd="", all equally prefixed elements are set in this namespace. All others (including elements without any prefix at all) are not in this namespace.Then, in your third example, you define a namespace for all unprefixed elements. This leads to the fact, that the unprefixed children of GSR are suddenly in the same namespace as their ancestor, not in the
nullnamespace they were before in 1 and 2.Edit: Just a small clarification:
sets the namespace to “http://aaa.yy.zz/Foo” for all elements that start with ‘fxd:’.
sets the namespace to “http://aaa.yy.zz/Foo” for all elements that have no colon in their name (= they are not prefixed).
If you want 1 and 2 to behave like 3, just add
somewhere before the first unprefixed element occurs. If you want it the other way round, you would have to prefix all elements you want to be in no namespace with, say, ‘bar:’ and add this somewhere:
thus explicitly setting them in the null namespace (as they are in the first two examples).