Skip to main content

IBM

Message Broker’s ASBITSTREAM function

I recently had a unique integration requirement where an external service provider was expecting XML within the SOAP request. One automatically thinks CDATA but in this case the endpoint required the XML to be escaped within a SOAP request.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
  <SOAP-ENV:Body>
  <ns1:CreateRequest>
  <ns1:Name>XML_Data</ns1:Name>
  <ns1:Value>&lt;order&gt; &lt;ns1:Attributes&gt; &lt;ns1:Name&gt;Transaction_ID&lt;/ns1:Name&gt;&lt;ns1:Value&gt;Transaction_ID goes here&lt;/ns1:Value&gt; &lt;/ns1:Attributes&gt; &lt;/order&gt;
  </ns1:Value>
  </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>

After multiple attempts trying to solve this with XSLT’s a colleague suggested why not move back to ESQL and use the ASBITSTREAM function. A few minutes later the below ESQL snippet proves once again why Message Broker is a true Enterprise ESB.

SET soapReq.ns:Objects.ns:Subscribers.ns:Attributes[1].ns:Name='XML_Data';
 SET myMsgBlob = ASBITSTREAM(InputRoot.XMLNSC.Order, 
                                       InputRoot.Properties.Encoding, 
                                       InputRoot.Properties.CodedCharSetId, 
                                       '','','', 
                                       FolderBitStream );
  SET myMsgChar = CAST( myMsgBlob AS CHAR CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.MQMD.Encoding); 
 SET soapReq.ns:Objects.ns:Subscribers.ns:Attributes[1].ns:Value = myMsgChar;

 

What’s next?

If you’re still using WebSphere Message Broker, it might be time to think about upgrading your ESB. Whether you’re using an unsupported version of WMB or want the features of the newest IIB release, use our best practices compiled over the course of countless migrations to ease the process and maximize your IBM investment.

WMB to IIB

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Arnold Shoon

Solutions Director with 10+ years focused on IBM based large enterprise SOA solutions.

More from this Author

Follow Us