1

我正在通过 WSO2ESB 中的 XSLT 将 XML 请求转换为 SOAP,只是想知道是否可以使请求参数可用于响应?

例如

<request>
<test>123</test>
<param1>testing</param1>
</request>

-> 转换为 SOAP

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">#S:Body><ns2:testrequest xmlns:ns2="http://xml.testing.com/test"><teststring>testing</teststring></ns2:testrequest></S:Body></S:Envelope></soapenv:Body></soapenv:Envelope>

在回应中

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:testresponse xmlns:ns2="http://xml.testing.com/test"><responsestring>success</responsestring></ns2:testresponse></S:Body></S:Envelope></soapenv:Body></soapenv:Envelope>

我想以 XML 格式返回

<responsestring>
<test>123</test>
<return1>success</return1>
</responsestring>

如您所见, 123 没有发送到服务器,也没有从服务器接收。但是,客户端正在发送此参数,我只想在请求中使用此参数并发送回响应,这可能吗?怎么办?我对突触很陌生,对 WSO2ESB 也很陌生,有人可以赐教吗?

谢谢。

4

2 回答 2

0

对的,这是可能的。您可以在 Insequence 中使用属性 mediator将所需的值设置为属性,然后使用丰富的 mediator将其添加到 outsequence 中以响应。

于 2012-10-31T02:43:03.280 回答
0

Got it working now. Simply by adding the property mediator in both insequence and outsequence together with the XSLT, where the xslt is trying to get the value from test property. That's it!

Insequence

 <property xmlns:ns="http://org.apache.synapse/xsd" name="TEST" expression="//request/*[local-name()=test]" scope="default"/>

outsequence

<xslt key="xxxx.xslt">
<property name="test" expression="get-property('TEST')"/>
</xslt>
于 2012-10-31T09:28:49.860 回答