Author |
Message
|
sraghukumar |
Posted: Wed Sep 26, 2012 10:54 am Post subject: base64binary to charecter message |
|
|
Apprentice
Joined: 15 Feb 2011 Posts: 49
|
Hi All,
I generated events in the message broker, I am using base64binary encoding to generated the body of the message. Now i need to get my orignal message from the generated events, can someone tell me how to convert(decode) back to blob or char(xml) from the base64binary encoding.
I am working on wmb 7, using esql for transformation, Any suggestion or help is greatly appreciated.
<p:bitstreamDataQuery p:bitstreamContent="body" p:encoding="base64binary"/>
below is the event message i have generated from the flow.
Code: |
<wmb:event xmlns:wmb="http://www.ibm.com/xmlns/prod/websphere/messagebroker/6.1.0/monitoring/event">
<wmb:eventPointData>
<wmb:eventData wmb:productVersion="7003" wmb:eventSchemaVersion="6.1.0.3" wmb:eventSourceAddress="FTTWSMsgControl.FO_FF.terminal.in">
<wmb:eventIdentity wmb:eventName="COM_setMsgType.INterminal"/>
<wmb:eventSequence wmb:creationTime="2012-09-25T23:35:05.575497Z" wmb:counter="1"/>
<wmb:eventCorrelation wmb:localTransactionId="07dbaf14-0769-11e2-94f0-000000000000-1" wmb:parentTransactionId="" wmb:globalTransactionId=""/>
</wmb:eventData>
<wmb:messageFlowData>
<wmb:broker wmb:name="SACSUN7B" wmb:UUID="9995edde-b18e-11e0-bc9f-000000000000"/>
<wmb:executionGroup wmb:name="WebSvc001" wmb:UUID="25a0783f-3101-0000-0080-a78b9bb51f34"/>
<wmb:messageFlow wmb:uniqueFlowName="SACSUN7B.WebSvc001.src.FTT_WebSvc_Request" wmb:name="src.FTT_WebSvc_Request" wmb:UUID="09aa8dfa-3901-0000-0080-86fd218a084d" wmb:threadId="73"/>
<wmb:node wmb:nodeLabel="FTTWSMsgControl.FO_FF" wmb:nodeType="ComIbmFlowOrderNode" wmb:terminal="in"/>
</wmb:messageFlowData>
</wmb:eventPointData>
<wmb:bitstreamData>
<wmb:bitstream wmb:encoding="base64Binary">TUQgIAAAAAIAAAAAAAAACP////8AAAAAAAA
BEQAABLhNUVNUUiAgIAAAAAMAAAABQU1RIFNBQ1NVTjdCICAgIFBTKbYgEk0
ZQU1RIFNBQ1NVTjdCICAgIFBTKbYgEk0/////zxzb2FwZW52OkVudmVsb3BlIH
htbG5zOnNvYXBlbnY9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3NvYXAv
ZW52ZWxvcGUvIiB4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDE
vWE1MU2NoZW1hIiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMD
EvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxuczp3c2E9Imh0dH6RW52ZWxvc
GU+Cg==</wmb:bitstream>
</wmb:bitstreamData>
</wmb:event> |
|
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 26, 2012 11:41 am Post subject: Re: base64binary to charecter message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sraghukumar wrote: |
can someone tell me how to convert(decode) back to blob or char(xml) from the base64binary encoding. |
Did you even try to answer this question yourself? If so, how did you miss the BASE64DECODE ESQL function? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sraghukumar |
Posted: Wed Sep 26, 2012 12:09 pm Post subject: |
|
|
Apprentice
Joined: 15 Feb 2011 Posts: 49
|
Hi Victor,
Appreciate for your response.
I even tried BASE64DECODE ESQL function, what that dose it, it will give me blob msg..
converting from blob to xml is little tricky here.. Where in i get "Parsing Errors have occurred", even thought its string forward conversion, that why i was looking some suggestion.
Let me put that part of ESQL.
DECLARE nsWMB NAMESPACE 'http://www.ibm.com/xmlns/prod/websphere/messagebroker/6.1.0/monitoring/event';
DECLARE rInMsgTree REFERENCE TO InputRoot.XMLNSC.nsWMB:event;
DECLARE rInMsgBitStreamData REFERENCE TO rInMsgTree.nsWMB:bitstreamData;
DECLARE cBitStream BLOB BASE64DECODE(rInMsgBitStreamData.nsWMB:bitstream);
CALL CopyMessageHeaders();
CREATE LASTCHILD OF OutputRoot.XMLNSC DOMAIN('XMLNSC') PARSE(cBitStream, InputProperties.Encoding, InputProperties.CodedCharSetId, 'BLOB', 'XML');
After the last line of code, i get parse error. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 26, 2012 12:23 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sraghukumar wrote: |
I even tried BASE64DECODE ESQL function, what that dose it, it will give me blob msg.. |
Gosh. If only there was some way of converting a BLOB to a CHARACTER. You'd think IBM would have built a CAST function like they have in other languages.
 _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sraghukumar |
Posted: Wed Sep 26, 2012 1:24 pm Post subject: |
|
|
Apprentice
Joined: 15 Feb 2011 Posts: 49
|
@Vitor,
Even the cast function is not giving the charter values. Here is some of the methods i have tried.
SET blBitStreamBLOB = CAST(rInMsgBitStreamData.nsWMB:bitstrea AS BLOB CCSID InputProperties.CodedCharSetId ENCODING InputProperties.Encoding);
SET D= CAST(cBitStream AS CHARACTER CCSID InputProperties.CodedCharSetId ENCODING InputProperties.Encoding);
SET D2 = CAST(D1 AS CHARACTER); |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 26, 2012 2:37 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Your ESQL looks OK.
Quote: |
After the last line of code, i get parse error. |
What did the parse error say? Maybe there's a clue in the error message. |
|
Back to top |
|
 |
deepak.gowder |
Posted: Fri Sep 28, 2012 4:37 am Post subject: |
|
|
Novice
Joined: 19 Sep 2012 Posts: 20
|
See if this helps -
Code: |
DECLARE DecodedAcord BLOB base64Decode(Environment.Variables.Acord103);
DECLARE Decoded2Acord CHARACTER CAST(DecodedAcord AS CHARACTER CCSID 1208);
DECLARE inCCSID INT InputProperties.CodedCharSetId;
DECLARE inEncoding INT InputProperties.Encoding;
CREATE LASTCHILD OF OutputRoot.XMLNSC.Acord103 DOMAIN('XMLNSC') PARSE(Decoded2Acord, inEncoding, inCCSID, 'CHARACTER', 'XMLNSC');
---------------
CREATE PROCEDURE base64Decode(IN source CHARACTER)
RETURNS BLOB
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.javacompute.Base64.decode";
|
Cheers! |
|
Back to top |
|
 |
kimbert |
Posted: Fri Sep 28, 2012 4:43 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
@deepak.gowder: Why would the OP want a Java-based base64decode() solution when he clearly is already using the ESQL BASE64DECODE function? |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Sep 28, 2012 5:06 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
kimbert wrote: |
@deepak.gowder: Why would the OP want a Java-based base64decode() solution when he clearly is already using the ESQL BASE64DECODE function? |
Well... they might...
IF the OP was using a version of broker where the BASE64DECODE Function wasn't available.
But as they have indicated that they are using V7 then you have a good point. _________________ 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 |
|
 |
deepak.gowder |
Posted: Fri Sep 28, 2012 11:59 am Post subject: |
|
|
Novice
Joined: 19 Sep 2012 Posts: 20
|
kimbert wrote: |
@deepak.gowder: Why would the OP want a Java-based base64decode() solution when he clearly is already using the ESQL BASE64DECODE function? |
Because I was using a version 7 too but not 7.0.0.2, where the function is available.
Cheers! |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Sep 28, 2012 8:19 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need to read up on the CREATE PARSE command. The examples you provided show that you don't have any idea of what you are doing.
You do not provide the folder vs root option and the last exemple with message set information may be good but looks highly suspicious from the content...so back to the infocenter!
Also what you have is an event message with the bitstream byte 64 encoded. There is no telling whether the event message will have the same CCSID and encoding as the original message.
Jeff may correct me but it could just be that the CCSID and encoding you are trying to use in your PARSE command are just plain wrong!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|