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 » [solved]embedding a Adobe pdf file in a xml message

Post new topic  Reply to topic
 [solved]embedding a Adobe pdf file in a xml message « View previous topic :: View next topic » 
Author Message
ydsk
PostPosted: Tue Sep 25, 2007 1:03 pm    Post subject: [solved]embedding a Adobe pdf file in a xml message Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Hi,

An application wants to send a pdf file embedded in a xml msg onto a broker, which would transform it into a different xml ( with the pdf file content) and drop it into a target queue.

We, the broker team need to give the xml format and the application will comply with it.

Any ideas on how a pdf file ( or any other binary data) can be embedded in an xml ? can we use CDATA / PCDATA / other tags ?

Pls advise.

thanks.
ydsk.


Last edited by ydsk on Wed Sep 26, 2007 11:27 am; edited 1 time in total
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Sep 25, 2007 1:09 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

CDATA will be very likely to protect it.

CDATA containing base64 encoding will guarantee.

CData sections can hold anything that is NOT a CData closing tag. So if somehow your PDF contained the binary code for a CData closing tag, your XML is no longer valid.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ydsk
PostPosted: Tue Sep 25, 2007 6:42 pm    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Thanks Jeff.
Can you pls provide a sample line of ESQL on how to do both encoding AND decoding with base64 ?

I know it is using the CAST statement but I just need to look at some ESQL sample.....

Thanks.
ydsk.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Sep 25, 2007 7:12 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It's not done using CAST.

If you dig around you can find an ESQL definition of a Java procedure defined on MbJavaComputeNode that will do base64 encoding
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ydsk
PostPosted: Wed Sep 26, 2007 9:02 am    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

I was able to do the base64 encoding part that the sending application should do (in a test msgflow). I called com.ibm.broker.javacompute.Base64.encode thru an external procedure for the purpose.
I did this precisely:
I sent the pdf file saved as a text using rfhUtil to this flow and it seems to work ( the output msg has all base64 characters ):
MQInput ( domain:BLOB) ---> Compute---->MQoutput

SET OutputRoot.MQMD.Domain = 'XML';
SET OutputRoot.MQMD.Format = 'MQSTR ';
SET OutputRoot.XML.Message.Header = 'some data';
SET OutputRoot.XML.Message.Body = base64Encode(InputRoot.BLOB.BLOB);
-- I defined base64Encode as an external procedure that calls the built-in procedure com.ibm.broker.javacompute.Base64.encode.

--------------- my next task is ------------------>

Now I need to decode it in my main msgflow but I don't know how to call com.ibm.broker.javacompute.Base64.decode from within ESQL. I want to do the exact opposite of my test flow here.

I tried this but it's failing:
I used the output of my test flow as the input for this main flow.

MQInput ( domain:XML) ---> Compute---->MQoutput

SET OutputRoot.MQMD.Domain = 'BLOB';
SET OutputRoot.BLOB.BLOB = base64Decode(InputRoot.XML.Message.Body);
-- where I defined base64Decode as an external procedure that calls the built-in procedure com.ibm.broker.javacompute.Base64.decode, and the input datatype is a CHAR.

But it is failing.
Can someone pls tell me how to make my main flow do the base64 decode ?

Thank you.
ydsk.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Sep 26, 2007 9:06 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

What's failing? I mean, what's the error.

I haven't looked at the decode method in a while, it may be that you don't have the ESQL procedure definition correct.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ydsk
PostPosted: Wed Sep 26, 2007 10:15 am    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Yep, the external java procedure was declared incorrectly.

I changed it to return BLOB and everything worked fine.

Just to let you all know, I didn't use any CDATA.

Thanks.
ydsk.
Back to top
View user's profile Send private message
ydsk
PostPosted: Wed Sep 26, 2007 11:33 am    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

For the benefit of others in the forum, here are the correct declarations of encode / decode procedures in ESQL ( just add them to the ESQLs of the 2 flows above along with the 2 built-in procedures CopyMessageHeaders, and CopyEntireMessage) :

CREATE PROCEDURE base64Encode(IN source BLOB)
RETURNS CHARACTER
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.javacompute.Base64.encode";

CREATE PROCEDURE base64Decode(IN source CHAR)
RETURNS BLOB
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.javacompute.Base64.decode";

thanks.
ydsk.
Back to top
View user's profile Send private message
petervh
PostPosted: Fri Oct 26, 2007 4:43 am    Post subject: Reply with quote

Apprentice

Joined: 15 Jun 2006
Posts: 31

Basic question:

Where can I find

com.ibm.broker.javacompute.Base64.encode

Is this a class supplied with a SupportPac ? How do I incorporate it into the broker environment?

Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Oct 26, 2007 5:00 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It's built into the product in v6. There's nothing you need to do to "find" it, other than insert the ESQL DECLARE statements above.

If you're not using v6 or later, you can't do this.
_________________
I am *not* the model of the modern major general.
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 » [solved]embedding a Adobe pdf file in a xml message
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.