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 » HTML or URL Encoding in WMB

Post new topic  Reply to topic
 HTML or URL Encoding in WMB « View previous topic :: View next topic » 
Author Message
Amitha
PostPosted: Fri Apr 09, 2010 10:32 am    Post subject: HTML or URL Encoding in WMB Reply with quote

Voyager

Joined: 20 Nov 2009
Posts: 80
Location: Newyork

Hi,

Please let me know how to do URL encoding or HTML encoding in WMB.
I know we can do this in Java ( for URL encoding java.net.URLEncoder.encode), Is there any built in CCSID or any other way to do the encoding.

For HTML encoding I need to convert

Code:
<?xml version="1.0" encoding="UTF-8"?>

to

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Fri Apr 09, 2010 11:24 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.

Forgive me for asking, but WHY are you wanting to do this?

What you seem to be wanting to do (By your example) is just to 'escape' the XML.
I'm sure Kimbert (or someone just as expert) will be along soon to help
_________________
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
Amitha
PostPosted: Fri Apr 09, 2010 11:39 am    Post subject: Reply with quote

Voyager

Joined: 20 Nov 2009
Posts: 80
Location: Newyork

Quote:
What you seem to be wanting to do (By your example) is just to 'escape' the XML.
I'm sure Kimbert (or someone just as expert) will be along soon to help


We have an legacy application where we need to send the Whole XML document as an HTML encoded string.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Fri Apr 09, 2010 1:21 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Is there any built in CCSID or any other way to do the encoding.
No - your best bet is to call a Java method from ESQL, or do the job in a JavaCompute node.
btw, that's a really strange use of the term 'CCSID'. Are you sure you meant that?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Apr 09, 2010 8:36 pm    Post subject: Reply with quote

Grand High Poobah

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

kimbert wrote:
Quote:
Is there any built in CCSID or any other way to do the encoding.
No - your best bet is to call a Java method from ESQL, or do the job in a JavaCompute node.
btw, that's a really strange use of the term 'CCSID'. Are you sure you meant that?


And there I thought that just assigning the unescaped XML string to an XML element in the tree would give you the escaped XML as a result...
Of course going with a CDATA type element would make more sense...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mgk
PostPosted: Sat Apr 10, 2010 2:51 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Can you explain a little more about what you expect the output message to look like. You mention "java.net.URLEncoder.encode" but then posted an example that did not use this encoding as the java URLEncoder will give a "%xx" encoding, not "&lt;" etc. Also what node are you sending this data out of? Are you actually making an HTTPRequest and want to send the data as part of a querystring or the body?


Kind regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
cool_ziv
PostPosted: Mon Apr 12, 2010 8:32 am    Post subject: Check previous forum Reply with quote

Newbie

Joined: 24 Nov 2009
Posts: 8

Quote:
Please let me know how to do URL encoding or HTML encoding in WMB.
I know we can do this in Java ( for URL encoding java.net.URLEncoder.encode), Is there any built in CCSID or any other way to do the encoding.


Hope this may help you.

Quote:
http://www.mqseries.net/phpBB2/viewtopic.php?t=52623
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Apr 12, 2010 9:35 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

mgk's question is an important one. I was answering the question about URL encoding ( based on the class name that Amitha quoted).
Quote:
nd there I thought that just assigning the unescaped XML string to an XML element in the tree would give you the escaped XML as a result...
Yes, if basic XML escaping is what is required, then it will happen automatically.

Amitha: it would probably help if you could explain exactly what kind of escaping you want, and why. There are various ways of encoding a snippet of XML within another XML document.
Back to top
View user's profile Send private message
Amitha
PostPosted: Mon Apr 12, 2010 12:09 pm    Post subject: Reply with quote

Voyager

Joined: 20 Nov 2009
Posts: 80
Location: Newyork

Thanks for the replies.

Actually I have two different requirements, 1) URL encoding 2) HTML encoding.

My apologies to include just one example.

Code:


Requirement 1:
WMB will have to send an HTTP POST request with data being URL encoded:

Content-type: application/x-www-form-urlencoded
Content-Length: 8484

method=<methodname>
data=<%3C%3Fxml+version%3D%221.0%22%3F%3E%0A>

Requirement2:

WMB will receive an SOAP request with XML message as HTML escaped string in the body and will have to return response in the same format.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getmethod xmlns:ns1="namespace " SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<inputXML xsi:type="xsd:string">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;request&gt;message &lt;request&gt;</inputXML>
</ns1:getmethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

we need to parse the HTML escaped XML string embedded in the SOAP.



For URL encoding(Requirment 1) I can make use of the java method I mentioned.

But for HTML escaping(Requiement 2), I am using esql REPLACE method to replace the escape characters and then parse using CREATE statement.

Quote:
btw, that's a really strange use of the term 'CCSID'. Are you sure you meant that?


I was thinking we can make use of CAST with CCSID for URL encoding(ISO-8859-1). As per infocentre ISO-8859-1 aliases to 819, but when I casted the string with this ccsid it didn't encode the characters.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Apr 12, 2010 2:06 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
for HTML escaping(Requiement 2), I am using esql REPLACE method to replace the escape characters and then parse using CREATE statement.

Have you actually checked the contents of the message tree before running your ESQL decoding algorithm ( using Trace node / debugger)?

All XML parsers automatically decode character refs like &lt; and &gt;. XMLNSC certainly does, and so you should get a CHARACTER field in the message tree which contains decoded XML.

Quote:
I was thinking we can make use of CAST with CCSID for URL encoding(ISO-8859-1). As per infocentre ISO-8859-1 aliases to 819, but when I casted the string with this ccsid it didn't encode the characters.
You are getting confused between character encodings ( i.e. code pages / ccsids ) and escaping mechanisms like URL encoding. It is probably worth spending some time to learn the difference - otherwise you are going to have a difficult time as an integration developer
Back to top
View user's profile Send private message
Amitha
PostPosted: Mon Apr 12, 2010 2:18 pm    Post subject: Reply with quote

Voyager

Joined: 20 Nov 2009
Posts: 80
Location: Newyork

Hi Kimbert,

Thank you for suggestion. I figured out that XMLNSC parser does decode escape characters automatically.

But, for URL encoding there is no other way than Java.
Back to top
View user's profile Send private message Send e-mail
cool_ziv
PostPosted: Mon Apr 12, 2010 2:28 pm    Post subject: Reply with quote

Newbie

Joined: 24 Nov 2009
Posts: 8

Quote:
But, for URL encoding there is no other way than Java.


Yes (AFAIK), you have to use Java method java.net.URLEncoder.encode(String,'UTF-8') for URL Encoding but for this you have to use JCN instead of Compute Node as you cannot call this method from ESQL since this method contains a THROWS clause. There is another method java.net.URLEncoder.encode(String) for the same without throws clause but this one is deprecated.
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 » HTML or URL Encoding in WMB
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.