Author |
Message
|
yortch |
Posted: Tue Aug 25, 2009 7:22 am Post subject: Simplest way to output XML in WMB 6.1? |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
I need to be able to log/print the XML that is sent to a Web Service for debugging purposes. What is the easiest way to accomplish this? Ideally I'd like to accomplish this via a built-in (or custom) ESQL function that returns the XML as a string so that I can add it to "debug" level logs.
Any pointers/suggestions for doing this will be appreciated.  |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Aug 25, 2009 7:34 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
The easiest way is to use a trace node passing it the ${InputRoot.XMLNSC} but this isnt really suitable for production systems.
Failing this, if you really do want to log each and every message id look at storing it as a CLOB in a DB somewhere.
I've got a feeling that if you add it to the "debug" user trace logs, the data will get truncated so this probably isnt your best solution |
|
Back to top |
|
 |
yortch |
Posted: Tue Aug 25, 2009 7:50 am Post subject: |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
I've tried this, the problem is that the output is not formatted in XML. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 25, 2009 8:04 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You mean you want to get a character representation of the message bitstream? |
|
Back to top |
|
 |
yortch |
Posted: Tue Aug 25, 2009 8:12 am Post subject: |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
mqjeff wrote: |
You mean you want to get a character representation of the message bitstream? |
Exactly |
|
Back to top |
|
 |
yortch |
Posted: Tue Aug 25, 2009 10:03 am Post subject: |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
I figured out a way to do this using Java. If anyone can add the ESQL equivalent please do...
Caller flow:
Code: |
DECLARE xmlString CHARACTER;
SET xmlString = common.XmlToString(OutputRoot.XMLNSC); |
ESQL function (to call Java function):
Code: |
CREATE FUNCTION XmlToString(IN xml REFERENCE)
RETURNS CHARACTER
LANGUAGE JAVA EXTERNAL NAME "common.utilities.log.LogHelper.xmlToString";
|
Java function:
Code: |
public static String xmlToString(MbElement xml) {
String xmlStr = xml.toString();
try {
byte[] data = xml.toBitstream("", "", "", 0, 0, 0);
xmlStr = new String(data);
}
catch (Exception any) {
LOGGER.error("Error converting XML bytes into string: " + any.toString());
}
LOGGER.debug("XML string: " + xmlStr);
return xmlStr;
}
|
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 25, 2009 10:12 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You've already found the ASBITSTREAM esql function.
Go back to the documentation, and look for the function that will let you express a BLOB field as a CHARACTER variable. |
|
Back to top |
|
 |
jbanoop |
Posted: Tue Aug 25, 2009 10:46 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
you can use the ASBITSTREAM to convert the tree into bytes. Then use a CAST to convert the bitstream into character if required.
Does this help ? |
|
Back to top |
|
 |
yortch |
Posted: Tue Aug 25, 2009 11:11 am Post subject: |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
Here is the ESQL equivalent:
Code: |
CAST(ASBITSTREAM(InputExceptionList) AS CHARACTER CCSID 1208) |
|
|
Back to top |
|
 |
|