on 11-10-2016 3:53 PM
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:
<soapenv:Envelope xmlns:soapenv="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
Try with XML Anonymizer Bean. Go through the example.
http://www.saptechnical.com/Tutorials/XI/XMLPayload/Index.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nabendu,
Thanks for that .I am trying to use the Anonymizer bean
https://blogs.sap.com/2014/10/02/remove-namespace-by-xmlanonymizer-bean-in-communication-channel/
wondering if the namespace can be removed from body
Does this XML anonymizer bean works to remove namespace for SOAP Body element ?In my example to remove xmlns=“http://xyz.com/“ ?In my case the SOAP body element has <ns0:Element xmlns:ns0=”http://www.xxxxx.com/wfm/”> I need to remove the namespace but needs to replace the prefix ns0 with wfm for all the elements in the SOAP Body .
I will try to execute and see the output .
Thanks and Regards,
Ra
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>
<wfm:GetAvailableSlotsxmlns:wfm=" 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy,
1.I tried to test the Web service using SOAP UI removing the prefix and send the request.It is giving an exception .The system would need the prefix before the elements.
2.In this case so i need two XSLT mappings after my message mapping from source (SAP Proxy ) to Target (Web Service Structure).First XSLT to create the SOAP Header and SOAP Body and the XSLT the second XSLT given by you above to insert wfm as prefix before each elements in the body ?
I am creating SOAP Envelope in XSLT mapping because the system would expect the header data :
<opt:OptionalParameters>
<opt:CallerIdentity>xxxxxx</opt:CallerIdentity>
<opt:ErrorOnNonExistingDictionaries>true</opt:ErrorOnNonExistingDictionaries>
</opt:OptionalParameters>
and insert the Web servive structure in the SOAP body where the Web Service Strucutre is
<ns0:GetAvailableSlots xmlns:ns0="http://www.xxxxx.xom/wfm/">
<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>
Please let me know if my understanding is correct. Sorce---->Message Mapping + XSLT 1 (Create SOAP Envelope) +XSLT 2 (insert prefix into the elements of the Structure in SOAP Body)--> Target
Thanks and Regards,
Raj
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 .
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.