1
votes

I try to use the WSO2 ESB with the SAP Solution Manager Webservice as an endpoint. For sending a message to the Webservice I need to modify the SOAP Header. While searching with google I found out that I could use the Enrich Mediator for this. But I couldn't find an example how to add the prefix to the header.

What I have is this:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<urn:ReadCompleteIncident>
<IncidentGuid>xxxxx</IncidentGuid>
<SystemGuid>xxx</SystemGuid>
</urn:ReadCompleteIncident>
</soapenv:Body>
</soapenv:Envelope>

But I get an error because the ESB doesn't know the prefix "urn:". So I have to add "xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"" to the Header for getting this:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style">
<soapenv:Body>
<urn:ReadCompleteIncident>
<IncidentGuid>xxxxx</IncidentGuid>
<SystemGuid>xxx</SystemGuid>
</urn:ReadCompleteIncident>
</soapenv:Body>
</soapenv:Envelope>

How can I do this with the Enrich Mediator? Or is there another solution?

Thank you :)

3

3 Answers

2
votes

You can use the Header mediator of WSO2 ESB to achieve your requirement.

<header name="Action" value="urn:ReadCompleteIncident"/>

You can refer this link to find more information.

http://docs.wso2.org/wiki/display/ESB460/Header+Mediator

1
votes

I solved this problem with Enrich Mediator. For example, here is my proxy.

Input message to ESB:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Header/>
   <soap:Body>
      <content>Message content</content>
   </soap:Body>
</soap:Envelope>

Required Input message to SAP PI:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xxxx">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:xxxx>
         <content>Message content</content>
      </urn:xxxx>
   </soapenv:Body>
</soapenv:Envelope>

Solution:

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="WSO2toSAP"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
         <property name="FORCE_SC_ACCEPTED"
                   value="true"
                   scope="axis2"
                   type="STRING"/>
         <log level="full"/>
         <enrich>
            <source type="body" clone="true"/>
            <target type="property" property="INPUT_MESSAGE"/>
         </enrich>
         <enrich>
            <source type="inline" clone="true">
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Body/>
               </soapenv:Envelope>
            </source>
            <target type="envelope"/>
         </enrich>
         <enrich>
            <source type="inline" clone="true">
               <urn:xxxx xmlns:urn="urn:xxxx"/>
            </source>
            <target type="body"/>
         </enrich>
         <enrich>
            <source type="property" clone="true" property="INPUT_MESSAGE"/>
            <target type="body" action="child"/>
         </enrich>
         <log level="full"/>
         <send>
            <endpoint key="WSO2toSAP_endpoint"/>
         </send>
      </inSequence>
   </target>
   <description/>
</proxy>

I hope, that I help you :)

0
votes

I think there are multiple ways you can solve this problem -

  1. payloadFactory mediator to manipulate the request or response.

  2. using script mediator - check this page http://abeykoon.blogspot.com/2013/03/encoding-and-decoding-xml-using-wso2-esb.html#comment-form for more details on how to use the script. As you can see, the blogger is generating the request using payloadFactory and then manipulate it using the scripts to get the desired effect.

If I find time, I will try to build a quick solution for you using the scripts.

All the best..