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 » Creating XML document in Java Node, get empty msg

Post new topic  Reply to topic
 Creating XML document in Java Node, get empty msg « View previous topic :: View next topic » 
Author Message
DevNYC1
PostPosted: Wed Oct 03, 2012 9:23 am    Post subject: Creating XML document in Java Node, get empty msg Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Wed Oct 03, 2012 9:31 am    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Wed Oct 03, 2012 9:41 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Looks like your missing an outBody with associated parser.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Wed Oct 03, 2012 7:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Creating XML document in Java Node, get empty msg
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.