0

Good day!

I only recently began to study the ESB bus. I need to convert the incoming SOAP message in the HTTP request with Content-Type: application/x-www-form-urlencoded.

I have created a Proxy Service, Custom Mediator 1 in Java, transformed message, how do I pass it to the endpoint and get the answer in Custom Mediator 2?

In the picture I have drawn an example of how to transform the message.

enter image description here

Community
  • 1
  • 1

2 Answers2

0

You don't need to write custom mediators, you can transform SOAP to rest calls, sample with a rest service waiting for 2 parameters like

param1=value1&param2=value2

<!-- prepare data for org.apache.axis2.transport.http.XFormURLEncodedFormatter message formatter -->
<payloadFactory media-type="xml">
    <format> 
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
            <soapenv:Body> 
                <root> 
                    <param1>$1</param1> 
                    <param2>$2</param2> 
                </root> 
            </soapenv:Body> 
        </soapenv:Envelope> 
    </format> 
    <args> 
        <arg evaluator="xml" expression="$body/node1/node11/text()"/> 
        <arg evaluator="xml" expression="$body/node1/node12/text()"/> 
   </args> 
</payloadFactory>  

<!-- set output format -->

<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/> 
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/> 

<!-- call the REST endpoint with synch call : response is received in this sequence -->

<call> 
   <endpoint key="conf:endpoints/MyServiceEndpoint.xml"/> 
</call> 

<!-- the response is here, transform it has needed -->
<xslt key="myxsl"/>

<!-- send this response to the client -->
<property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/>  
<!-- or test/xml and in this case, don't forget to specify a SOAP Action, below, a sample to specify a blank soapAction : -->
<header name="Action" value="&quot;&quot;"/>
<send/>

Sample endpoint conf (with this sample, you need to define a property uri.var.ServiceURL in your sequence) :

<endpoint>
  <http method="POST" uri-template="{uri.var.ServiceURL}/Path/2011-10-01"/>
</endpoint>

But if you really need your custom mediators, just replace payloadFactory and xslt mediators with them

Jean-Michel
  • 5,926
  • 1
  • 13
  • 19
0

Thanks for the reply, I still have to write custom mediator, just a very complex transformation messages I will give an example how should I transform the message

  1. SOAP message in my Proxy Service, send in custrom mediator
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <AddPay xmlns="http://MyTestService">
      <!--input dynamic data-->
      <fields>
        <Items>
          <Data>
            <Name>Field1</Name>
            <Value>11</Value>
          </Data>
          <Data>
            <Name>Field2</Name>
            <Value>22</Value>
          </Data>
        </Items>
      </fields>
    </AddPay>
  </soap:Body>
</soap:Envelope>
  1. The result of the transformation of the mediator
0000035401SM000000970000009700000121
api99             00000990
                  00000000
BEGIN     // <!--input dynamic data-->
FIELD1=11 // Soap data
FIELD2=22 // Soap data
END

BEGIN SIGNATURE
iQBRAwkBAAAD3j2r2NwBAeevAf4nvAG4rGAyAePHkyVKTt7wffzURhOckd3ctgmG
yQkKWkXh3CLpsbrExsllVUBlO6ih8qHozk2uttXApzHXQXoO
=+pch
END SIGNATURE
  1. Request to the HTTP Server
POST /cgi-bin/es/es_pay_check.cgi HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 498
inputmessage=0000035401SM000000970000009700000121%0D%0Aapi99+
+++++++++++00000990%0D%0A++++++++++++++++++++00000000%0ABEGIN%0D%
0FIELD1%11%0FIELD2%220AEND%0D%0ABEGIN+SIGNATURE%0AiQBRAwkBAABCiUs
00dQBATG5AgDHdZ6RYHykL46QBaAvnHYaY4p0pDjgjO4K1Iyj%0D%0AfSBSvCRpS%2
F0EYO9NspuyLeANEQQkkGE%2F37gUxiPqzAgStXjpsAHH%0D%0A%3DvSgb%0AEND+
SIGNATURE
  1. The response from the HTTP Server, pass in custrom mediator to transform into SOAP
0000030301SM000000460000004600000121
0J0005            00064182
                  00000000
BEGIN
DATE=04.10.2014 12:34:12
ERROR=0
ERRMSG=
FIELD3=33
FIELD4=44
FIELD5=55
END
BEGIN SIGNATURE
iQBRAwkBAAD6tj1BJ10BAYKxAfsHlQsEFnO2k6ry++W8O8AiJuv4gT+ZVCfZHsKk
c0CbZpP/W3vkljG3xNzMLiqjbwkNuIdwR9Dq7gHmH+ZQMhbT
=LOnP
END SIGNATURE
  1. The result in the Proxy service
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <AddPayResponse xmlns="http://MyTestService">
      <AddPayResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <Data>
          <Items>
            <!--output dynamic data-->
            <Data>
              <Name>Field3</Name>
              <Value>33</Value>
            </Data>
            <Data>
              <Name>Field4</Name>
              <Value>44</Value>
            </Data>
            <Data>
              <Name>Field5</Name>
              <Value>55</Value>
            </Data>
          </Items>
        </Data>
        <ErrCode>0</ErrCode>
        <ErrMsg>Ok</ErrMsg>
      </AddPayResult>
    </AddPayResponse>
  </s:Body>
</s:Envelope>