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 » XML Message in JavaCompute Node & convert it to a FileSt

Post new topic  Reply to topic
 XML Message in JavaCompute Node & convert it to a FileSt « View previous topic :: View next topic » 
Author Message
Rahul999
PostPosted: Tue Feb 16, 2010 10:09 pm    Post subject: XML Message in JavaCompute Node & convert it to a FileSt Reply with quote

Centurion

Joined: 14 Mar 2007
Posts: 134

Hi All,


I am receiving an XML message via MQ which I am passing to JavaCompute Node, now my objective is to retrieve the String out of XML message and pass it to the Input Buffered Stream as a String.

But, I am not able to get the whole XML message as a String. Following is the code I am using but it is giving me NullPointerException(because the value at the end is null).


Quote:

public void evaluate(MbMessageAssembly contact admin) throws MbException {
MbElement root = contact admin.getMessage().getRootElement();
MbElement body = root.getLastChild(); //gives XMLNSC
bElement message = body.getFirstChild(); //gives first tag of XMLNSC
String test1 = (String)VASMessage.getValue(); //getting Null


In the above code , I am getting the value of "test1" as null, whereas I am looking to get some string. I am supposed to pass this string to an InputBufferedStream.
Please anyone suggest how I can get a complete String for an XML message.

Thanks.
_________________
"For all your days be prepared, and meet them ever alike.
When you are the anvil, bear - when you are the hammer, strike."
- Edwin Markham
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Gaya3
PostPosted: Tue Feb 16, 2010 10:16 pm    Post subject: Re: XML Message in JavaCompute Node & convert it to a Fi Reply with quote

Jedi

Joined: 12 Sep 2006
Posts: 2493
Location: Boston, US

Rahul999 wrote:

But, I am not able to get the whole XML message as a String. Following is the code I am using but it is giving me NullPointerException(because the value at the end is null).

Please anyone suggest how I can get a complete String for an XML message.



Read about bitstream[createElementAsLastChildFromBitstream] functionality in MB Java
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
Rahul999
PostPosted: Tue Feb 16, 2010 10:49 pm    Post subject: Reply with quote

Centurion

Joined: 14 Mar 2007
Posts: 134

Hi Gaya3,

Quote:
Read about bitstream[createElementAsLastChildFromBitstream] functionality in MB Java


If I understand correctly, the createElementAsLastChildFromBitstream is for generating the output message. but as per my requirement I need to handle the XML message in Input end only. I need to convert it into String and then do some string manipulation and then pass it to the ClientSocket connection.

What I am trying to get the value of whole XML message.

Quote:

<Body>
<Request>
<BillPayment>
<TransactionType>BILL PAYMENT</TransactionType>
<InstrumentType>ACCOUNT</InstrumentType>
<AmountPaid>100</AmountPaid>
</BillPayment>
</Request>
</Body>
</VASMessage


Like in the above XML message, I need to convert it into a String format so that I can pass it to Buffered reader. I am using getValue() on MBElement but it is not working.
_________________
"For all your days be prepared, and meet them ever alike.
When you are the anvil, bear - when you are the hammer, strike."
- Edwin Markham
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kimbert
PostPosted: Wed Feb 17, 2010 12:01 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I am receiving an XML message via MQ which I am passing to JavaCompute Node, now my objective is to retrieve the String out of XML message and pass it to the Input Buffered Stream as a String.
The solution is trivial. Parse the message in the BLOB domain, and then convert InputRoot.BLOB.BLOB to a string in the correct code page. You will probably need to use Java's CharsetDecoder class for that.


However, I would like to know *why* you want to pass the entire input message into a Java stream.
Back to top
View user's profile Send private message
Rahul999
PostPosted: Wed Feb 17, 2010 11:59 pm    Post subject: Reply with quote

Centurion

Joined: 14 Mar 2007
Posts: 134

Hi Kimbert,

thanks for reply.

Quote:
However, I would like to know *why* you want to pass the entire input message into a Java stream.


I need to take that input message and then pass it to a socket port as a request. Before that I need to do some string manipulation so I can not directly use TCPIP node.

Thanks
_________________
"For all your days be prepared, and meet them ever alike.
When you are the anvil, bear - when you are the hammer, strike."
- Edwin Markham
Back to top
View user's profile Send private message Send e-mail Visit poster's website
smdavies99
PostPosted: Thu Feb 18, 2010 3:41 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

What sort of string manipulation do you need to do?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Rahul999
PostPosted: Sun Feb 21, 2010 5:22 pm    Post subject: Reply with quote

Centurion

Joined: 14 Mar 2007
Posts: 134

Quote:

What sort of string manipulation do you need to do?



Appending the length of message at the beginning of message in big endian ascii format.

Regards,
_________________
"For all your days be prepared, and meet them ever alike.
When you are the anvil, bear - when you are the hammer, strike."
- Edwin Markham
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kimbert
PostPosted: Mon Feb 22, 2010 1:40 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Using a Java stream sounds like using a sledgehammer to crack a nut.

ESQL can tell you the length of the CHARACTER field. Then you can convert that to a BLOB containing ASCII characters ( endianness is irrelevant for ASCII, btw ) using a CAST and append the resulting bytes to the BLOB.

Sort of like this:
Code:
SET myString = CAST InputRoot.BLOB.BLOB AS CHARACTER CCSID InputRoot.Properties.CodedCharsetId ENCODING InputRoot.Properties.Encoding;
SET strLength = LENGTH(myString);
SET lengthAsCharacter = CAST strLength AS CHARACTER;
SET lengthAsBLOB = CAST lengthAsCharacter AS BLOB CCSID <ascii code page>;
SET messageWithLength = InputRoot.BLOB.BLOB || lengthAsBLOB;

Not tested, probably not even syntactically correct, but you get the idea.
I suspect that the second and third CAST statements could be combined into a single CAST which converts from INTEGER to BLOB.
Back to top
View user's profile Send private message
vikashsharma85
PostPosted: Wed Jun 23, 2010 1:46 am    Post subject: Reply with quote

Novice

Joined: 19 Mar 2010
Posts: 15

I would Like to use the same thread for my Query:

I have a message parsed in BLOB domain,I want to retrieve my BLOB data in the Java Compute Node as Byte array .

I am using following code snippet:
--------------------------------------------------
MbElement body = root.getLastChild();
MbElement BLOB=body.getFirstChild();
String dataString=(String)BLOB.getValue();
byte[] responseBytes =dataString.getBytes();
------------------------------------------------------

This portion of Code is throwing NULL pointer exception,

Code:
String dataString=(String)BLOB.getValue();


Though in Debugger i am able to see some value for BLOB element->
MbElement( type: 3000000 name: BLOB value: [B@639a639a )

I am not sure why getValue() function is throwing exception, when object is valid.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jun 23, 2010 10:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

vikashsharma85 wrote:
I would Like to use the same thread for my Query:

I have a message parsed in BLOB domain,I want to retrieve my BLOB data in the Java Compute Node as Byte array .

I am using following code snippet:
--------------------------------------------------
MbElement body = root.getLastChild();
MbElement BLOB=body.getFirstChild();
String dataString=(String)BLOB.getValue();
byte[] responseBytes =dataString.getBytes();
------------------------------------------------------

This portion of Code is throwing NULL pointer exception,

Code:
String dataString=(String)BLOB.getValue();


Though in Debugger i am able to see some value for BLOB element->
MbElement( type: 3000000 name: BLOB value: [B@639a639a )

I am not sure why getValue() function is throwing exception, when object is valid.

Think about it... This is more or less what I would expect.
You are casting from the BLOB to String... I would not dare... Too many byte values have no equivalent in String....
Why not directly do something like byte[] mybytes=BLOB.getValue()???
_________________
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 » XML Message in JavaCompute Node & convert it to a FileSt
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.