Skip to Content
0
Former Member
Aug 02, 2016 at 05:19 AM

Generate escape characters in the XML

1051 Views

Hi Guys,

I have requirement to generate the escape characters in the XML message:

My input message:

<?xml version="1.0" encoding="UTF-8"?>
<SiebelMessage ErrorMessage="INVALID STATE/COUNTRY" ErrorCode="1020" MsgType="Cr" IntObjectFormat="Siebel Hierarchical" IntObjectName="HS" MessageType="Integration">
<ListOfServiceProvider>
<ServiceProvider>
<Id>1</Id>
<SAPVendorNumber/>
</ServiceProvider>
</ListOfServiceProvider>
</SiebelMessage>

Using XSLT mapping to generate SOAP wrapper:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asi="http://siebel.com/asi/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:template match="/">
  <SOAP:Envelope>
  <soapenv:Header>
  <wsse:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
  <wsse:UsernameToken>
  <wsse:Username>O</wsse:Username>
  <wsse:Password Type="wsse:PasswordText">O</wsse:Password>
  </wsse:UsernameToken>
  </wsse:Security>
  </soapenv:Header>
  <soapenv:Body>
        <asi:HS1_spcGeneric_spcInbound_spcIntegration_spcWS_spcWrapper_Execute_Input>
  <asi:_XMLMessage>
  <xsl:copy-of select="." />
  </asi:_XMLMessage>
  </asi:HS1_spcGeneric_spcInbound_spcIntegration_spcWS_spcWrapper_Execute_Input>
    </soapenv:Body>
  </SOAP:Envelope>
  </xsl:template>
</xsl:stylesheet>


<

Output after executing above XSL:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asi="http://siebel.com/asi/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
      <wsse:UsernameToken>
        <wsse:Username>O</wsse:Username>
        <wsse:Password Type="wsse:PasswordText">O</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </soapenv:Header>
  <soapenv:Body>
    <asi:HS1_spcGeneric_spcInbound_spcIntegration_spcWS_spcWrapper_Execute_Input>
      <asi:_XMLMessage>
        <SiebelMessage ErrorMessage="INVALID STATE/COUNTRY" ErrorCode="1020" MsgType="Cr" IntObjectFormat="Siebel Hierarchical" IntObjectName="HS" MessageType="Integration">
          <ListOfServiceProvider>
            <ServiceProvider>
              <Id>1</Id>
              <SAPVendorNumber/>
            </ServiceProvider>
          </ListOfServiceProvider>
        </SiebelMessage>
      </asi:_XMLMessage>
    </asi:HS1_spcGeneric_spcInbound_spcIntegration_spcWS_spcWrapper_Execute_Input>
  </soapenv:Body>
</SOAP:Envelope>

Expectation is to have the XML content in present in <asi:_XMLMessage> parameters with escape characters as shown below:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asi="http://siebel.com/asi/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
      <wsse:UsernameToken>
        <wsse:Username>O</wsse:Username>
        <wsse:Password Type="wsse:PasswordText">O</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </soapenv:Header>
  <soapenv:Body>
    <asi:HS1_spcGeneric_spcInbound_spcIntegration_spcWS_spcWrapper_Execute_Input>
      <asi:_XMLMessage>
        &lt;SiebelMessage ErrorMessage=&quot;INVALID STATE/COUNTRY&quot; ErrorCode=&quot;1020&quot; MsgType=&quot;Cr&quot; IntObjectFormat=&quot;Siebel Hierarchical&quot; IntObjectName=&quot;HS&quot; MessageType=&quot;Integration&quot;&gt;
          &lt;ListOfServiceProvider&gt;
            &lt;ServiceProvider&gt;
              &lt;Id&gt;1&lt;/Id&gt;
              &lt;SAPVendorNumber/&gt;
            &lt;/ServiceProvider&gt;
          &lt;/ListOfServiceProvider&gt;
        &lt;/SiebelMessage&gt;
      </asi:_XMLMessage>
    </asi:HS1_spcGeneric_spcInbound_spcIntegration_spcWS_spcWrapper_Execute_Input>
  </soapenv:Body>
</SOAP:Envelope>

Please suggest if there is a way to convert the unescaped characters into escape characters by modifying in the same above XSL code?

Thanks.

Regards,

AJ