Skip to Content
avatar image
Former Member

XML prefix in the SOAP Header and Body message

Hi Team,

We are trying to integrate an application using SAP PO and the application expects SOAP Header with the sender system ID where the header can be created using XSLT mapping with the SOAP body included from the Message Mapping as discussed in the thread.

https://archive.sap.com/discussions/thread/3883963

The SOAP body included from the Message Mapping has ns0 as the xml prefix where my structure that needs to be passed is expected as below:

http://schemas.xmlsoap.org/soap/envelope/" xmlns:opt=" http://www.clicksoftware.com/OptionalParameters" xmlns:wfm=" http://www.xxxxxxx.com/wfm/">

<soapenv:Header>

<opt:OptionalParameters>

<opt:CallerIdentity>xxxxxx</opt:CallerIdentity> <opt:ErrorOnNonExistingDictionaries>true</opt:ErrorOnNonExistingDictionaries>

</opt:OptionalParameters>

</soapenv:Header>

<soapenv:Body>

<wfm:GetAvailableSlots>

<wfm:Period>

<wfm:Start>2016-09-12T08:00:00</wfm:Start>

<wfm:Finish>2016-09-19T18:00:00</wfm:Finish>

</wfm:Period>

<wfm:Task>

<wfm:TaskType>DNPG</wfm:TaskType>

<wfm:District>xxxxxx</wfm:District>

<wfm:Duration>1800</wfm:Duration>

<wfm:Priority>4</wfm:Priority>

<wfm:Latitude>44336957</wfm:Latitude>

<wfm:Longitude>-69811731</wfm:Longitude>

<wfm:NotificationType>MM</wfm:NotificationType>

<wfm:RespServiceCenter>RS</wfm:RespServiceCenter>

</wfm:Task>

<wfm:Profile>Full Day</wfm:Profile>

</wfm:GetAvailableSlots>

</soapenv:Body>

</soapenv:Envelope>

Could you please let me know how to create XML prefixes or replace XML prefixes with the required one ? The XML included in the body is generated from XSD imported from the external application.

Request your help on the same.

Thanks and Regards,

Raj

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Nov 22, 2016 at 03:44 PM

    Try with XML Anonymizer Bean. Go through the example.

    http://www.saptechnical.com/Tutorials/XI/XMLPayload/Index.htm

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 10, 2016 at 11:37 PM

    Hi Raj!

    Can you confirm that using "ns0" prefix in your message instead of "wrm" leads to errors in end-to-end testing?

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Evgeniy,

      I have not tested End to End as there is some firewall issue which we are currently working up on.I am hoping that this will give an error and one more thing to add is the response sent from the receiver application all the elements will have a prefix which SAP runtime will not allow .I tried to use the receiving test message in the test tab and it is giving me mapping error .

      Thanks for your reply .Do let me know if you need any additional details.

      Thanks and Regards,

      Raj

  • Nov 14, 2016 at 05:17 AM

    Hi Rajesh!

    You can use this XSLT:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

    xmlns:opt=" http://www.clicksoftware.com/OptionalParameters"

    xmlns:wfm=" http://www.xxxxxxx.com/wfm/"

    xmlns:ns0=" http://www.xxxxxxx.com/wfm/"

    version="1.0" exclude-result-prefixes="ns0">

    <xsl:output indent="yes"/>

    <xsl:template match="/">

    <soapenv:Envelope>

    <xsl:apply-templates select="//soapenv:Envelope/*"/>

    </soapenv:Envelope>

    </xsl:template>

    <xsl:template match="@*|node()">

    <xsl:element name="{name()}">

    <xsl:apply-templates select="@*|node()"/>

    </xsl:element>

    </xsl:template>

    <xsl:template match="ns0:*">

    <xsl:element name="wfm:{local-name()}">

    <xsl:apply-templates select="@*|node()"/>

    </xsl:element>

    </xsl:template>

    <xsl:template match="@ns0:*">

    <xsl:attribute name="wfm:{local-name()}">

    <xsl:value-of select="."/>

    </xsl:attribute>

    </xsl:template>

    <xsl:template match="text()|comment()|processing-instruction()">

    <xsl:copy/>

    </xsl:template>

    </xsl:stylesheet>

    For input XML like:

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

    <soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

    xmlns:opt=" http://www.clicksoftware.com/OptionalParameters"

    xmlns:ns0=" http://www.xxxxxxx.com/wfm/">

    <soapenv:Header>

    <opt:OptionalParameters>

    <opt:CallerIdentity>xxxxxx</opt:CallerIdentity>

    <opt:ErrorOnNonExistingDictionaries>true</opt:ErrorOnNonExistingDictionaries>

    </opt:OptionalParameters>

    </soapenv:Header>

    <soapenv:Body>

    <ns0:GetAvailableSlots>

    <ns0:Period>

    <ns0:Start>2016-09-12T08:00:00</ns0:Start>

    <ns0:Finish>2016-09-19T18:00:00</ns0:Finish>

    </ns0:Period>

    <ns0:Task>

    <ns0:TaskType>DNPG</ns0:TaskType>

    <ns0:District>xxxxxx</ns0:District>

    <ns0:Duration>1800</ns0:Duration>

    <ns0:Priority>4</ns0:Priority>

    <ns0:Latitude>44336957</ns0:Latitude>

    <ns0:Longitude>-69811731</ns0:Longitude>

    <ns0:NotificationType>MM</ns0:NotificationType>

    <ns0:RespServiceCenter>RS</ns0:RespServiceCenter>

    </ns0:Task>

    <ns0:Profile>Full Day</ns0:Profile>

    </ns0:GetAvailableSlots>

    </soapenv:Body>

    </soapenv:Envelope>


    it produces output like:

    <?xml version="1.0" encoding="utf-8"?>

    <soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:opt=" http://www.clicksoftware.com/OptionalParameters">

    <soapenv:Header>

    <opt:OptionalParameters>

    <opt:CallerIdentity>xxxxxx</opt:CallerIdentity>

    <opt:ErrorOnNonExistingDictionaries>true</opt:ErrorOnNonExistingDictionaries>

    </opt:OptionalParameters>

    </soapenv:Header>

    <soapenv:Body>

    http://www.xxxxxxx.com/wfm/">

    <wfm:Period>

    <wfm:Start>2016-09-12T08:00:00</wfm:Start>

    <wfm:Finish>2016-09-19T18:00:00</wfm:Finish>

    </wfm:Period>

    <wfm:Task>

    <wfm:TaskType>DNPG</wfm:TaskType>

    <wfm:District>xxxxxx</wfm:District>

    <wfm:Duration>1800</wfm:Duration>

    <wfm:Priority>4</wfm:Priority>

    <wfm:Latitude>44336957</wfm:Latitude>

    <wfm:Longitude>-69811731</wfm:Longitude>

    <wfm:NotificationType>MM</wfm:NotificationType>

    <wfm:RespServiceCenter>RS</wfm:RespServiceCenter>

    </wfm:Task>

    <wfm:Profile>Full Day</wfm:Profile>

    </wfm:GetAvailableSlots>

    </soapenv:Body>

    </soapenv:Envelope>

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Evgeniy Kolmakov

      Hi Evgeniy,

      Unfortunately the XSLT code provided did not worked.Here is what I did :

      Output from Message Mapping:

      <?xml version="1.0" encoding="UTF-8"?>
      <ns0:GetAvailableSlots xmlns:ns0="http://www.xxxxxx.com/wfm/">
      <ns0:Period>
      <ns0:Start/>
      <ns0:Finish/>
      </ns0:Period>
      <ns0:Task>
      <ns0:CallID/>
      <ns0:Number/>
      <ns0:TaskType/>
      <ns0:District/>
      <ns0:Duration/>
      <ns0:Priority/>
      <ns0:Street/>
      <ns0:City/>
      <ns0:PostCode/>
      <ns0:State/>
      <ns0:CountryID/>
      <ns0:Latitude/>
      <ns0:Longitude/>
      </ns0:Task>
      <ns0:Profile/>
      </ns0:GetAvailableSlots>

      XSLT Mapping 1 and Output :

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:opt="http://www.clicksoftware.com/OptionalParameters" xmlns:wfm="http://www.xxxxx.com/wfm/">
      <soapenv:Header>
      <opt:OptionalParameters>
      <opt:CallerIdentity>EAI_SAP</opt:CallerIdentity>
      <opt:ErrorOnNonExistingDictionaries>true</opt:ErrorOnNonExistingDictionaries>
      </opt:OptionalParameters>
      </soapenv:Header>
      <soapenv:Body>
      <xsl:copy-of select="*"/>
      </soapenv:Body>
      </soapenv:Envelope>
      </xsl:template>
      </xsl:stylesheet>

      Output :

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope xmlns:opt="http://www.clicksoftware.com/OptionalParameters" xmlns:wfm="http://www.xxxxx.com/wfm/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Header>
      <opt:OptionalParameters>
      <opt:CallerIdentity>EAI_SAPCRM</opt:CallerIdentity>
      <opt:ErrorOnNonExistingDictionaries>true</opt:ErrorOnNonExistingDictionaries>
      </opt:OptionalParameters>
      </soapenv:Header>
      <soapenv:Body>
      <ns0:GetAvailableSlots xmlns:ns0="http://www.xxxxx.com/wfm/">
      <ns0:Period>
      <ns0:Start/>
      <ns0:Finish/>
      </ns0:Period>
      <ns0:Task>
      <ns0:CallID/>
      <ns0:Number/>
      <ns0:TaskType/>
      <ns0:District/>
      <ns0:Duration/>
      <ns0:Priority/>
      <ns0:Street/>
      <ns0:City/>
      <ns0:PostCode/>
      <ns0:State/>
      <ns0:CountryID/>
      <ns0:Latitude/>
      <ns0:Longitude/>
      </ns0:Task>
      <ns0:Profile/>
      </ns0:GetAvailableSlots>
      </soapenv:Body>
      </soapenv:Envelope>

      I used your XSLT mapping provided above as an XSLT mapping 2 but it is not working as expected and is providing the prefix elements.Could you please help me if we can use the XSLT in XSLT Mapping 1 to replace the prefix and remove namespace from

      <ns0:GetAvailableSlots xmlns:ns0="http://www.xxxxx.com/wfm/"> to provide the required input to the application ?

      It will help if you can provide the XSLT code .