|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Reading Message element in JavaCompute |
« View previous topic :: View next topic » |
Author |
Message
|
goffinf |
Posted: Mon Apr 28, 2008 11:29 am Post subject: Reading Message element in JavaCompute |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
version: 6.0
I am trying to read the names and values of various parts of an inbound message in a Java node, but I am not getting what I expect. In this case the message inbound is actually a SOAP Fault but that probably doesn't matter. Anyway this is what is happening :-
inbound message :
<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soap:Server</faultcode>
<faultstring>something bad happened</faultstring>
<faultactor>urn:someEndpoint</faultactor>
<detail>
<NUError xmlns="urn:aviva:nu:dis:schema:entities:common:nuerror:v01">
<ErrorID>99999</ErrorID>
<ErrorType>UNEXPECTED</ErrorType>
<ErrorDescription>Boooom</ErrorDescription>
<TimeStamp>2008-04-24T15:28:51Z</TimeStamp>
</NUError>
</detail>
</soap:Fault>
in Java node :-
public int run(MbMessageAssembly ma) throws MbException {
...
MbElement xmlnscRoot;
MbElement soapFaultRoot;
MbMessage msg = null;
...
msg.getRootElement().createElementAsLastChildFromBitstream(msgBytes, MbXMLNSC.PARSER_NAME, null, null, null, 0, 1208, 0);
MbMessageAssembly newAssembly = new MbMessageAssembly(ma, msg);
msg.finalizeMessage(MbMessage.FINALIZE_VALIDATE);
// get the parser domain (XMLNSC)
xmlnscRoot = newAssembly.getMessage().getRootElement().getLastChild();
// get the name of the root node (should be Fault)
soapFaultRoot = xmlnscRoot.getFirstChild();
String rootNodeName = soapFaultRoot.getName();
String rootNodeNamespace = soapFaultRoot.getNamespace();
// Everything OK so far : rootNodeName = 'Fault' and rootNodeName contains the SOAP 1.1 namespaceURI
// IF I TRY TO HAVE A LOOK AT THE FIRST CHILD THINGS GO AWRY ??
String soapFaultRootChildName;
soapFaultRootChildName = soapFaultRoot.getFirstChild().getName();
At this point soapFaultRootChildName contains the value 'soap', that is the prefix of the Fault element ??
I can use an evaluateXPath method to get to the child nodes of Fault (faultcode, faultstring, etc..) so why can't I do it with getFirstChild or any of the other methods ???
Thanks
Fraser. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 28, 2008 11:33 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The first child of soap:Fault is likely to be xmlns:soap... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
goffinf |
Posted: Mon Apr 28, 2008 1:38 pm Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
jefflowrey wrote: |
The first child of soap:Fault is likely to be xmlns:soap... |
Jeff,
you're right, but why, thats just the namespace declaration for that node. What am I not understanding here ?
Is it to do with the way the XMLNSC parser works ??
Fraser. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Apr 28, 2008 4:35 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Is it to do with the way the XMLNSC parser works ? |
It certainly is. Here's your chance to learn something important:
- The message broker tree is not a DOM tree
- Attributes are children of the parent tag
- Child elements are also children of the parent tag
So how can the programmer tell the difference?
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac67192_.htm
That's a v6.1 page, by the way. If on v6.0, section 'Field types for controlling output format' and everything afterwards does not apply. |
|
Back to top |
|
 |
goffinf |
Posted: Tue Apr 29, 2008 12:03 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
kimbert wrote: |
Quote: |
Is it to do with the way the XMLNSC parser works ? |
It certainly is. Here's your chance to learn something important:
- The message broker tree is not a DOM tree
- Attributes are children of the parent tag
- Child elements are also children of the parent tag
So how can the programmer tell the difference?
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac67192_.htm
That's a v6.1 page, by the way. If on v6.0, section 'Field types for controlling output format' and everything afterwards does not apply. |
Thanks, I am familiar using this style in eSQL, but how do I ask for the first field of [say] TYPE element (XMLNSC.Field) in Java ?
E.g.
MBElement soapFaultRoot;
soapFaultRoot = xmlnscRoot.getFirstChild();
How do I change the above to say the first child of type XMLNSC.Field ?
Fraser. |
|
Back to top |
|
 |
goffinf |
Posted: Tue Apr 29, 2008 12:07 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
Ok, not so good example since there should only be a single child of root, so lets say :-
MBElement soapFaultRoot;
MBElement firstChild;
soapFaultRoot = xmlnscRoot.getFirstChild();
firstChild= soapFaultRoot .getFirstChild();
How do I change the above to say the first child of type XMLNSC.Field ?
goffinf wrote: |
E.g.
MBElement soapFaultRoot;
soapFaultRoot = xmlnscRoot.getFirstChild();
How do I change the above to say the first child of type XMLNSC.Field ?
Fraser. |
|
|
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
|
|
|
|