|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Creating XML document in Java Node, get empty msg |
« View previous topic :: View next topic » |
Author |
Message
|
DevNYC1 |
Posted: Wed Oct 03, 2012 9:23 am Post subject: Creating XML document in Java Node, get empty msg |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 32
|
I am using the sample code from this IBM Help page: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ac30340_.htm?path=1_7_7_2_1_0_1_3#ac30340_
to create a simple XML message in my Java node, but the resulting flow puts an empty XML msg (length = 0) on the resulting "out" queue. Any idea what I am doing wrong?
Code: |
public void evaluate(MbMessageAssembly inMsgAssembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbMessage inMessage = inMsgAssembly.getMessage();
// create new message
MbMessage outMessage = new MbMessage();
MbMessageAssembly outMsgAssembly = new MbMessageAssembly(inMsgAssembly,
outMessage);
try {
// optionally copy message headers
copyMessageHeaders(inMessage, outMessage);
// ----------------------------------------------------------
// Add user code below
// Create a simple message
MbElement root = outMessage.getRootElement();
MbElement document = root.getLastChild().getFirstChild();
MbElement chapter2 = document.createElementAsLastChild(MbElement.TYPE_NAME,"Chapter",null);
// add title attribute
MbElement title2 = chapter2.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,
"title", "Message Flows");
// End of user code
out.propagate(outMsgAssembly);
}
finally {
// clear the outMessage even if there's an exception
outMessage.clearMessage();
}
} |
|
|
Back to top |
|
 |
kimbert |
Posted: Wed Oct 03, 2012 9:31 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Any idea what I am doing wrong? |
Not at first glance, although somebody else might see the problem immediately.
You should at least try to diagnose the problem yourself before asking for help. Otherwise we just waste our time and yours telling you to repeat things that you've already done. Have you used the debugger? Put in a Trace node or two? Taken a user trace? |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 03, 2012 9:41 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Oct 03, 2012 7:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
lancelotlinc wrote: |
Looks like your missing an outBody with associated parser. |
This is where you are going wrong:
Code: |
MbElement root = outMessage.getRootElement();
MbElement document = root.getLastChild().getFirstChild();
|
Your document reference is pointing to the first child of the last header...
a) you need to define a parser as last child of root
b) Even if defined it would not have a first child unless you defined it...
c) you are trying to read from a non existent place.
Maybe you meant to say inMessage instead of outMessage??
So try this (from memory)
Code: |
MbElement parser = root.createElementAsLastChild(MbXMLNSC.name);
MbElement xmlroot= parser.createElementAsLastChild(MbElement.TYPE_NAME,"mybook", null);
|
Have fun  _________________ 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
|
|
|
|