Author |
Message
|
bprasana |
Posted: Mon Jun 18, 2012 1:24 pm Post subject: namespace declaration a various levels of input XML |
|
|
 Disciple
Joined: 18 Apr 2005 Posts: 179
|
Hey guys,
I have a weird problem going on. I am recoding one of the WPS mediation flows in WMB.
This WPS flow takes messages from 2 different applications. For some historic reasons these 2 applications send messages LITTLE differently. Broker is not able to handle the namespace declared at the element level but apparently WPS can. Is this a known issue? or am i doing something wrong?
Here is an example:
Application 1 :
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<soapenv:Header/>
<soapenv:Body>
<addData xmlns="http://test">
<level1><level2>123</level2></level1>
</addData>
</soapenv:Body>
</soapenv:Envelope>
Application 2 :
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:test="http://test">
<soapenv:Header/>
<soapenv:Body>
<test:addData >
<level1><level2>123</level2></level1>
</test:addData>
</soapenv:Body>
</soapenv:Envelope>
Both XMLs validate against the wsdl in SOAPUI. But Broker is not able to parse the Application 1 message the same way as WPS.
I have declared test as namespace and using the following statements
This is the statement in database node
SET Environment.Variables.SOAP.messageHeader.*[] = Root.SOAP.Body.*[1].level1.*[];
and this one is in compute node
SET Environment.Variables.test = InputRoot.SOAP.Body.test:addData.level1.level2;
[/b] |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 18, 2012 1:27 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
so the "<level1>" element in message 1 has a namespace, and the "<level1>" element in message 2 does not. |
|
Back to top |
|
 |
bprasana |
Posted: Mon Jun 18, 2012 1:48 pm Post subject: |
|
|
 Disciple
Joined: 18 Apr 2005 Posts: 179
|
hmmm...not sure . I think none of the mesasge have namespace at level1.
both of them are getting validated though. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 18, 2012 1:55 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I could be wrong, but the
Code: |
<addData xmlns="http://test"> |
sets the default namespace for all elements under it.
Best thing is to take a Trace node output of the logical message tree and see what it says is the namespace on each element. |
|
Back to top |
|
 |
mgk |
Posted: Mon Jun 18, 2012 1:58 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
I could be wrong, but the Code:
<addData xmlns="http://test">
sets the default namespace for all elements under it. |
You are right. This means in one case Level1 and Level2 also have namespaces which need to be used when accessing these elements. In the other case they do not have namespaces which explains the differences between the messages. Broker CAN handle both of these messages, as long as you get your namespacing correct in your code...
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
bprasana |
Posted: Mon Jun 18, 2012 2:15 pm Post subject: |
|
|
 Disciple
Joined: 18 Apr 2005 Posts: 179
|
Thanks for the reply.
But both the messages get validated? weird!!
Also if the name space is declared at parent level, it should still work for both the scenarios since level1 is inside the declaration for both name spaces.
I guess thats because one of them dont have a 'name' for namespace.Can someone point to w3c standards regarding this anomaly?
The question that comes to my mind is - How is WPS handling this? But i guess its a question for different forum |
|
Back to top |
|
 |
mqsiuser |
Posted: Mon Jun 18, 2012 11:37 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
bprasana wrote: |
But both the messages get validated? weird!!
|
What is the tool with which you validate ?... did you try anything else than SOAP UI ?
The MS-XML parser had/has problems with "default namespaces" and would say you'd have an invalid xml (when opened in IE).
Search for an "ignore namespace" check box ... there are these kinds of check boxes in SOAP UI.
Post the relevant parts of the XSD/WSDL here in the forum.
Also:
1. There was a non-standards-conform implementation of accessing not prefixed / default namespaced nodes in Broker...
2. Probably WPS is relaxed about accessing elements/attributes ("ignore namespaces")... probably for good reason: The XML standard has a strange syntax on that. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
mapa |
Posted: Tue Jun 19, 2012 12:18 am Post subject: |
|
|
 Master
Joined: 09 Aug 2001 Posts: 257 Location: Malmö, Sweden
|
This is nothing strange and is actually noted by some of the responders to this post, but just to clarify:
In your example 1:
Code: |
<addData xmlns="http://test">
<level1><level2>123</level2></level1>
</addData>
|
This means that the all sub-elements of addData (like level1 and level2) belongs to the namespace "http://test". It is the default namespace since it is not prefixed.
In your example 2 you first declare the namespace prefix test on the root element (the soapenv:Envelope):
Code: |
<test:addData >
<level1><level2>123</level2></level1>
</test:addData>
|
This means that only addData belongs to the namespace "http://test". The sub-elements belongs to the implicit default namespace "".
This will probably drill down to your XML schema for the payload:
If default value for elementFormDefault (which is "unqualified") is used that means that only global elements and types will belong to the declared target namespace. And if qualified all named elements and types will belong to the target namespace.
The only requirement imposed on the WSDL 1.1 is if you want to be WS-I basic profile compliant, then the soap body needs to be namespace qualified. But only the root element of the body needs this, meaning that both examples are valid from that point of view. I guess this is the only thing soapUI is checking...
Namespaces in XML 1.0 |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jun 19, 2012 12:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
In case there is any doubt, everything that mapa said is correct. The mistake is yours. WPS is probably not 'validating' what you think it is validating. |
|
Back to top |
|
 |
bprasana |
Posted: Tue Jun 19, 2012 3:53 am Post subject: |
|
|
 Disciple
Joined: 18 Apr 2005 Posts: 179
|
Thanks for very detailed replies. Let me try those options in soap UI and verify my schema again.i will probably validate thexml in the toolkit . But the real problem is I cannot ask the end systems to change their payload since we are moving to WMB (however wrong they might be). I guess the only option I have is to write a separate code for each of these 2 consumers. Messy!!!  |
|
Back to top |
|
 |
Esa |
Posted: Tue Jun 19, 2012 4:00 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
bprasana wrote: |
I guess the only option I have is to write a separate code for each of these 2 consumers. Messy!!!  |
I seems you are not aware that you can use a wildcard namespace prefix like this:
SOAP.Body.*:addData.*:level1.*:level2 |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jun 19, 2012 4:03 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I guess the only option I have is to write a separate code for each of these 2 consumers. Messy! |
Yes. But the mess was created by whoever wrote the other applications. They made a fairly basic mistake with the namespaces.
WMB is ( quite correctly ) exposing an existing problem. If you don't want WMB to complain about the problem then could switch off validation in the WMB message flow. This will only work if the WMB error message was a validation error. You did not quote the error... |
|
Back to top |
|
 |
bprasana |
Posted: Tue Jun 19, 2012 4:11 am Post subject: |
|
|
 Disciple
Joined: 18 Apr 2005 Posts: 179
|
Esa,that's a solution I was looking for. Let me try that!!! Yes I was not aware of that.
Kimbert, I don't have a validation ON in WMB. I am only trying to access the element in my code. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jun 19, 2012 4:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
But you said
Quote: |
But Broker is not able to parse the Application 1 message the same way as WPS. |
That was not an accurate description of your problem. Message broker was successfully creating a message tree from the input XML ( so it was successfully parsing the XML ) but your ESQL was not returning the result that you expected.
Anyway, I agree with Esa - you need to use a wildcard in your ESQL. |
|
Back to top |
|
 |
|