3
美好的一天!WSO2。如何在XML中轉換SOAP消息並將其發送到服務?
最近,我開始學習WSO ESB
我的服務接收請求,並以XML格式的響應,例如:
<!--The query in my service --> POST/HTTP/1.1 Content-Type: text/xml; charset=utf-8 Content-Length: 109 <req> <Value>How are you?</Value> </req> <!--The response from the service --> HTTP/1.1 200 OK Content-Length: 120 Content-Type: text/xml; charset=utf-8 <res> <Value>Very good!!!</Value> </res>
我需要通過代理從客戶端轉換SOAP請求SOAP客戶端中的XML服務的示例
示例SOAP請求和代理服務中的響應
<!--The request from the client to proxy service--> <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> <Question xmlns="http://MyTestService"> <Value>How are you?</Value> </Question> </soap:Body> </soap:Envelope> <!--Answer the service proxy to the client--> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <QuestionResponse xmlns="http://CyberPlatService"> <Fun1Result>Very good!!!</Fun1Result> </QuestionResponse> </s:Body> </s:Envelope>
這裏是我的代理服務
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CyberPlatProxy" transports="https http" startOnLoad="true" trace="disable"> <target> <inSequence> <payloadFactory media-type="xml"> <format> <req> <Value>$1</Value> </req> </format> <args> <arg xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" expression="//Question/Value"/> </args> </payloadFactory> <property name="messageType" value="text/xml" scope="axis2" type="STRING"/> <property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/> <log level="custom"/> <send> <endpoint> <http method="post" uri-template="http://localhost:2009/"/> </endpoint> </send> </inSequence> <outSequence> <payloadFactory media-type="xml" description="res"> <format> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetStaysResponse xmlns="http://CyberPlatService"> <GetStaysResult>$1</GetStaysResult> </GetStaysResponse> </s:Body> </s:Envelope> </format> <args> <arg expression="//Value"/> </args> </payloadFactory> <property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/> <send/> </outSequence> <faultSequence/> </target> </proxy>
什麼也沒有發生,我究竟做錯了什麼?
謝謝,我已經糾正了。 – 2014-10-17 10:19:26