|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Semantically the same XML results in different logical trees |
« View previous topic :: View next topic » |
Author |
Message
|
bbakerman |
Posted: Tue Aug 01, 2006 12:18 am Post subject: Semantically the same XML results in different logical trees |
|
|
Apprentice
Joined: 17 Dec 2003 Posts: 41
|
I have used the MRM to define a web service schema and used the broker tooling to generate the WSDL file.
I am using broker v6.0.0.1 on Linux and the same toolkit on Windows. I have HttpInput nodes etc.. to receive the WS call.
I have used 2 WS clients, Apache Axis 1.4 and the toolkits inbuilt Web Services Explorer to invoke the web service.
They generate slightly different XML as their request and its seems cause a big problem to the broker MRM parser. Specifically when I used Web Services Explorer, the name space attributes are lost and hence my ESQL returns NULL instead of the XML values.
I used a HTTP proxy (from Axis) to capture the "on the wire" XML formats and then a trace node to show what broker builds as logical tree.
The WebServices Explorer send this
Code: |
<?xml version="1.0" encoding="UTF-8" ?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://www.lands.nsw.gov.au/webgov/landtitle" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SOAP-ENV:Body>
- <q0:landtitlerequest>
<searchtype>RT</searchtype>
<usercodes>fred</usercodes>
<titlereference>5/775888</titlereference>
<flags>N</flags>
</q0:landtitlerequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
and in the broker traces this as
Code: |
(
(0x01000000):Properties = (
(0x03000000):MessageSet = 'DIA620C002001'
(0x03000000):MessageType = 'Envelope'
(0x03000000):MessageFormat = 'XML1'
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 1208
(0x03000000):Transactional = FALSE
(0x03000000):Persistence = FALSE
(0x03000000):CreationTime = GMTTIMESTAMP '2006-08-01 07:06:39.601126'
(0x03000000):ExpirationTime = -1
(0x03000000):Priority = 0
(0x03000000):ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x03000000):ReplyProtocol = 'SOAP-HTTP'
(0x03000000):Topic = NULL
(0x03000000):ContentType = 'text/xml; charset=utf-8'
)
(0x01000000):HTTPInputHeader = (
(0x03000000):X-Original-HTTP-Command = 'POST http://srv-bx-mqt1:7080/webgov/landtitle HTTP/1.1'
(0x03000000):Host = 'srv-bx-mqt1:7080'
(0x03000000):Content-Type = 'text/xml; charset=utf-8'
(0x03000000):Content-Length = '488'
(0x03000000):Accept = 'application/soap+xml, application/dime, multipart/related, text/*'
(0x03000000):User-Agent = 'IBM Web Services Explorer'
(0x03000000):Cache-Control = 'no-cache'
(0x03000000):Pragma = 'no-cache'
(0x03000000):SOAPAction = '""'
(0x03000000):Connection = 'close'
)
(0x0100001B):MRM = (
(0x01000013)http://schemas.xmlsoap.org/soap/envelope/:Body = (
(0x0100001B)http://www.lands.nsw.gov.au/webgov/landtitle:landtitlerequest = (
(0x0300000D):searchtype = 'RT'
(0x0300000D):usercodes = 'fred'
(0x0300000D):titlereference = '5/775888'
(0x0300000D):flags = 'N'
)
)
)
)
|
Notice here the "searchtype" element does not have a namespace associated with it. This plays funny buggers with my ESQl access later on. Also note that the on the wire example use a namespace prefix of "q0" for my internal XML.
Apache Axis however generates a slightly different XML message on the wire
Code: |
<?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:Body>
<landtitlerequest xmlns="http://www.lands.nsw.gov.au/webgov/landtitle">
<searchtype>RT</searchtype>
<usercodes>webgov websphere test</usercodes>
<clientreference></clientreference>
<titlereference>5/775888</titlereference><flags>N</flags>
</landtitlerequest></soapenv:Body>
/soapenv:Envelope>
|
and this results in a broker trace of
Code: |
(
(0x01000000):Properties = (
(0x03000000):MessageSet = 'DIA620C002001'
(0x03000000):MessageType = 'Envelope'
(0x03000000):MessageFormat = 'XML1'
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 1208
(0x03000000):Transactional = FALSE
(0x03000000):Persistence = FALSE
(0x03000000):CreationTime = GMTTIMESTAMP '2006-08-01 07:06:39.601126'
(0x03000000):ExpirationTime = -1
(0x03000000):Priority = 0
(0x03000000):ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x03000000):ReplyProtocol = 'SOAP-HTTP'
(0x03000000):Topic = NULL
(0x03000000):ContentType = 'text/xml; charset=utf-8'
)
(0x01000000):HTTPInputHeader = (
(0x03000000):X-Original-HTTP-Command = 'POST http://srv-bx-mqt1:7080/webgov/landtitle HTTP/1.0'
(0x03000000):Content-Type = 'text/xml; charset=utf-8'
(0x03000000):Accept = 'application/soap+xml, application/dime, multipart/related, text/*'
(0x03000000):User-Agent = 'Axis/1.4'
(0x03000000):Host = 'srv-bx-mqt1:7080'
(0x03000000):Cache-Control = 'no-cache'
(0x03000000):Pragma = 'no-cache'
(0x03000000):SOAPAction = '""'
(0x03000000):Content-Length = '514'
)
(0x0100001B):MRM = (
(0x01000013)http://schemas.xmlsoap.org/soap/envelope/:Body = (
(0x0100001B)http://www.lands.nsw.gov.au/webgov/landtitle:landtitlerequest = (
(0x0300000B)http://www.lands.nsw.gov.au/webgov/landtitle:searchtype = 'RT'
(0x0300000B)http://www.lands.nsw.gov.au/webgov/landtitle:usercodes = 'webgov websphere test'
(0x0300000B)http://www.lands.nsw.gov.au/webgov/landtitle:clientreference = ''
(0x0300000B)http://www.lands.nsw.gov.au/webgov/landtitle:titlereference = '5/775888'
(0x0300000B)http://www.lands.nsw.gov.au/webgov/landtitle:flags = 'N'
)
)
)
)
|
Notice in this example the lower level elements such as "searchtype" have name space information and hence this ESQL works and also the different namespace declaration in the "one the wire" XML. Note that a namespace prefix is not being used but rather an xmls="" attribute.
My ESQL looks like this :
Code: |
create function buildRequest() returns char
begin
declare API_REQUEST char '';
set API_REQUEST = InputRoot.MRM.soapenv:Body.ns:landtitlerequest.ns:searchtype;
set API_REQUEST = API_REQUEST || '|' || InputRoot.MRM.soapenv:Body.ns:landtitlerequest.ns:usercodes;
if length(InputRoot.MRM.soapenv:Body.ns:landtitlerequest.ns:clientreference) > 0 then
set API_REQUEST = API_REQUEST || ' ' || InputRoot.MRM.soapenv:Body.ns:landtitlerequest.ns:clientreference;
end if;
set API_REQUEST = API_REQUEST || '|' || InputRoot.MRM.soapenv:Body.ns:landtitlerequest.ns:titlereference;
set API_REQUEST = API_REQUEST || '|' || InputRoot.MRM.soapenv:Body.ns:landtitlerequest.ns:flags;
return API_REQUEST;
end;
|
when the above code runs, if the namespace information is not present, then API_REQUEST will end up being NULL and hence not be built as expected
From my understanding of XML, the 2 input requests are equivalent, eg the former one defines a namspace prefix and uses it and the latter one uses an explicit namespace on the parent element.
The issue here is not whether I used Apache Axis as a client or the WS Explorer but rather that XML messages that are semantically the same result in a different logical tree and "missing" information from an ESQL point of view.
So my questions are :
1) Are the 2 XML fragments equivalent?
2) If so, shouldnt broker parse them into the same logical tree, with the appropriate namespace info?
3) Does broker have trouble with namespace prefixes as oppsed to xmlns attributes?
4) Has anyone else encountered this issue and what did they do to get around it.
ps. I apologize in advance if this has been answered before. I search the forums and found a lot on soap requests and namespaces but nothing with this specific issue listed, eg same semantically the same XML producing different trees. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Aug 01, 2006 1:44 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'm not an XML namespace expert.
Broker uses the Apache Xerxes parser.
I don't think your two fragments are semantically equivalent. I think the first declares that the element landtitlerequest belongs to the namespace http://www.lands.nsw.gov.au/webgov/landtitle, whereas the second declares that the element and it's children are in the namespace.
I'm not quite saying that right.
But I think broker is doing the right thing according to how you've written the XML. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Aug 01, 2006 1:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
I don't think these are the same. One specifies that elements prefixed "q0" are part of the namespace, the other specifies that all elements default to membership of that namespace.
This would seem to be what the trace is saying.
Disclaimer: what I know about SOAP would fit on the back of a postage stamp. What I know about namespaces would require the back of an envelope, but not a particually large one.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
msukup |
Posted: Tue Aug 01, 2006 9:03 am Post subject: |
|
|
Acolyte
Joined: 11 Feb 2002 Posts: 56
|
Vitor,
How is elementFormDefault and attributeFormDefault set in your xml schema?
If they are set to "qualified", namespaces will be prefixed as your example 2 (sent from Axis 1.4); if set to "unqualified", it is sent as your example 1 (sent from Web Services Explorer). My guess is that this attribute is missing altogether, so Web Services explorer api (IBM SOAP?) assumes unqualified, whereas axis 1.4 assumes qualified.
If this is a possibility, try changing just this element in the schema definition, then retry from Web services explorer and it should send with qualified namespaces. At leaset then, it is predicatable to mrm parser. . . . |
|
Back to top |
|
 |
bbakerman |
Posted: Tue Aug 01, 2006 4:34 pm Post subject: |
|
|
Apprentice
Joined: 17 Dec 2003 Posts: 41
|
Thank you all for the advice. It seems the elementFormDefault is exactly the issue. Whene I set elementFormDefault="qualified" in the generated schema .xsd file, WS Explorer starts to output fully qualified child elements as shown below.
Code: |
<?xml version="1.0" encoding="UTF-8" ?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://www.lands.nsw.gov.au/webgov/landtitle" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SOAP-ENV:Body>
- <q0:landtitlerequest>
<q0:searchtype>fre</q0:searchtype>
<q0:usercodes />
<q0:titlereference />
<q0:flags />
</q0:landtitlerequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
So my next question is :
1) Does any one know in terms of the broker tooling how to specify in the message set/ message definition file that elementFormDefault="qualified" should be used when exporting the schema?
I want to use the broker tooling to generate WSDL without having to remember to hand tweak it each time. I also want the "clients" of the WS to have as much XML meta information so they call the service in an appropriate manner. |
|
Back to top |
|
 |
msukup |
Posted: Wed Aug 02, 2006 5:14 am Post subject: |
|
|
Acolyte
Joined: 11 Feb 2002 Posts: 56
|
To have that attribute elementFormDefault set in generating the xsd and wsdl files, create the message definition in following way:
1) when creating the message set definition file, specify the target namespace that will qualify all elements (The message set project must be first created with namespaces enabled)
2) once the message definition has been created, create your message as you normally would. On the logical properties of the message definition file (.mxsd) properties, there are 2 properties to set under: Default namespace for local objects. These will sets these attributes for you when you create wsdl.
Btw, here is another problem with qualifiying namespaces that i have found and I would love the solution for, though it's not a message broker problem: although the wsdl that includes an xsd with namespaces works fine in MB 6.0 and its underlying environment (RAD ?), when I try to copy the generated wsdl files and directories containing xsd to WSAD 5.1, WSAD seems to think the wsdls are not syntactically correct due to the namespaces and xsd's dir structure. It's a bit frustrating, because I can't generate the client in WSAD with the perceived syntax errors, but I can't upgrade WSAD either. Anyone know a workaround besides creating xsd without namespaces?
-m |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Aug 02, 2006 4:18 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You might have to open the xsd and edit manually so that the paths are relative instead of absolute.
Check the import statements with schemalocation, The path there should be relative to a "root". If WSAD 5.1 is capable of handling namespaces, you will need to import the files in a proper relative structure in order for everything to work fine.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|