ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » how to get the sub xml string in the java compute node

Post new topic  Reply to topic
 how to get the sub xml string in the java compute node « View previous topic :: View next topic » 
Author Message
blackwhites
PostPosted: Tue Jan 27, 2009 7:11 pm    Post subject: how to get the sub xml string in the java compute node Reply with quote

Novice

Joined: 23 Jan 2009
Posts: 10

Hi all,I want to extract the part of xml String from the message broker how can I do it? For example the following is my sending xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<customer>
    <name>Leo</name>
    <phone>12345678</phone>
    <type>VIP</type>
    <desc>Plugin Testing</desc>
</customer>


I write a java compute node to handle it .

/**
* @see com.ibm.broker.plugin.MbNodeInterface#evaluate(MbMessageAssembly, MbInputTerminal)
*/
public void evaluate(MbMessageAssembly assembly, MbInputTerminal in) throws MbException {
MbMessage outMsg = null;
try{
outMsg = new MbMessage(assembly.getMessage());
MbOutputTerminal output = getOutputTerminal("out");
MbElement customerElement = outMsg.getRootElement ().getFirstElementByPath("/XML/customer");
//here I want to get the customerElement xml String
String xml= myapplication.method(xmlString);
MbMessageAssembly outputAssembly = new MbMessageAssembly(assembly, outMsg);
output.propagate(outputAssembly);
}finally{
if (outMsg != null){
outMsg.clearMessage();
}
}
}

You can see a bold line is my customer class ,the method has a parameter
it will invoke xml String. I want to pass the
Code:
<?xml version="1.0" encoding="UTF-8"?>
<customer>
    <name>Leo</name>
    <phone>12345678</phone>
    <type>VIP</type>
    <desc>Plugin Testing</desc>
</customer>
to it ,the problem is I can get the Mbelement ,but when I used Mbelement.toString() method,it didn't return the xml I posted here,can anyone provide API for me to get this xml in evaluate method? Notes: my message used XMLNSC type.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Tue Jan 27, 2009 8:19 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

If you're using XMLNSC, your argument for getFirstElementbyPath should probably contain "XMLNSC" instead of "XML".

MbElement.toString() does not serialize XML sub-trees for you. MbElement.toBitstream() could serialize the entire XML tree, but not a sub-tree.

You might have better luck using the ESQL ASBITSTREAM function with the FolderBitStream option.

If "myapplication.method()" is static, you can DECLARE it as an external procedure in your ESQL, and call it directly, and eliminate the java compute node.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 28, 2009 1:36 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Looks as if you need the entire input bitstream, including the xml declaration.
So you need
Code:
assembly.getMessage().toBitstream()


rekarm01 is correct about the XML/XMLNSC thing. The message body is always the last child of the root node, and its name is the name of the domain ( 'XMLNS'/'XMLNSC'/'MRM'/'JMS'etc ). But I hope you knew that already
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jan 28, 2009 2:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You now have two separate answers telling you what you have asked how to do.

You almost certainly DO NOT need to do what you have asked how to do.

What business requirement are you trying to fulfill? What transformation of the XML message are you trying to accomplish, that you think you need the "XML string"?
Back to top
View user's profile Send private message
blackwhites
PostPosted: Wed Jan 28, 2009 5:17 pm    Post subject: Reply with quote

Novice

Joined: 23 Jan 2009
Posts: 10

Thanks for your guys reply.Actually I am developing a customer node ,
in the customer GUI ,I defined a xpath field , I need to extract the mqinput xml according to the xpath, then I will pass the extract xml to myapplication.method(xmlString) get the new xml,then I need to write the newxml to the MQOUTPUT . I am not sure I used this method is good for implementation .Also I need your sugestion for doing this business application .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » how to get the sub xml string in the java compute node
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.