美好的一天!
我最近才开始研究ESB总线。我需要使用Content-Type转换HTTP请求中的传入SOAP消息:application / x-www-form-urlencoded。
我在Java中创建了一个代理服务,自定义中介1,转换了消息,如何将其传递到端点并在Custom Mediator 2中获得答案?
在图片中,我画了一个如何转换信息的例子。
答案 0 :(得分:0)
您不需要编写自定义调解器,您可以将SOAP转换为其余调用,使用等待2个参数的休息服务进行采样,例如
参数1 =值1&安培; param2的=值2
<!-- 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=""""/>
<send/>
示例端点conf(使用此示例,您需要在序列中定义属性uri.var.ServiceURL):
<endpoint>
<http method="POST" uri-template="{uri.var.ServiceURL}/Path/2011-10-01"/>
</endpoint>
但如果您真的需要自定义调解器,只需将payloadFactory和xslt调解器替换为它们
答案 1 :(得分:0)
感谢您的回复,我仍然需要编写自定义中介,只需要一个非常复杂的转换消息 我将举例说明如何转换消息
<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>
0000035401SM000000970000009700000121 api99 00000990 00000000 BEGIN // <!--input dynamic data--> FIELD1=11 // Soap data FIELD2=22 // Soap data END BEGIN SIGNATURE iQBRAwkBAAAD3j2r2NwBAeevAf4nvAG4rGAyAePHkyVKTt7wffzURhOckd3ctgmG yQkKWkXh3CLpsbrExsllVUBlO6ih8qHozk2uttXApzHXQXoO =+pch END SIGNATURE
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
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
<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>