我正在使用Wso2esb4.8.0 我希望根据适配器请求要求转换消息。 我以各种方式传入消息。 像
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/" xmlns:env="http://eai.mmn.gg/Envelope" xmlns:par="http://eai.mm.gg/par">
<soapenv:Header/>
<soapenv:Body>
<open:clientRequest>
<env:EaiEnvelope>
<env:Domain>1</env:Domain>
<env:Service>par</env:Service>
<env:ServiceId>1</env:ServiceId>
<env:Language>En</env:Language>
<env:uiId>sd</env:uiId>
<env:sid>sd</env:sid>
<env:MessageId>2210201395544</env:MessageId>
<env:CorrelationId>1</env:CorrelationId>
<env:GenTimeStamp>1</env:GenTimeStamp>
<env:SentTimeStamp>1</env:SentTimeStamp>
<env:Payload>
<par:par>
<par:Request>
<par:Operation_Name>getv</par:Operation_Name>
</par:Request>
</par:par>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
以上是每条消息的一种消息类型名称空间将被更改。 还有一个示例Request请求消息。这样我们就有10-15个请求消息
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/" xmlns:env="http://eai.mmn.gg/Envelope" xmlns:acc="http://eai.mm.gg/accounts">
<soapenv:Header/>
<soapenv:Body>
<open:clientRequest>
<env:EaiEnvelope>
<env:Service>par</env:Service>
<env:Language>En</env:Language>
<env:uiId>sd</env:uiId>
<env:sid>sd</env:sid>
<env:MessageId>2210201395544</env:MessageId>
<env:CorrelationId>1</env:CorrelationId>
<env:GenTimeStamp>1</env:GenTimeStamp>
<env:SentTimeStamp>1</env:SentTimeStamp>
<env:Payload>
<acc:par>
<acc:Request>
<acc:CustDetails_InputData>
<acc:MSISDN>989105496</acc:MSISDN>
</acc:CustDetails_InputData>
<acc:Operation_Name>getv</acc:Operation_Name>
</acc:Request>
</acc:par>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
在每个Payload数据中一直在不断变化,因此要求是为所有转换为所需格式的请求写入单个Xquery。 在Xquery转换之后,将这样的内容添加到上面的消息中。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/" xmlns:acc="http://eai.mm.kman/acf">
<soapenv:Header/>
<soapenv:Body>
<open:getv>
<acc:acf>
<!--You have a CHOICE of the next 3 items at this level-->
<acc:Request>
<acc:Operation_Name>getv</acc:Operation_Name>
<acc:BasicInfo>
<acc:Language>En</acc:Language>
<acc:h>sd</acc:h>
<acc:sid>sd</acc:sid>
<acc:MessageId>2210201395544</acc:MessageId>
<acc:Operation>getv</acc:Operation>
</acc:BasicInfo>
<acc:CustDetails_InputData>
<acc:MSISDN>989352105496</acc:MSISDN>
</acc:CustDetails_InputData>
</acc:Request>
</acc:acf>
</open:getv>
</soapenv:Body>
</soapenv:Envelope>
XQuery转换后输出的另一个请求消息是。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/" xmlns:par="http://eai.mm.kman/par">
<soapenv:Header/>
<soapenv:Body>
<open:getv>
<par:par>
<par:Request>
<par:BasicInfo>
<par:Language>En</par:Language>
<par:uiId>sd</par:uiId>
<par:sid>sd</par:sid>
<par:MessageId>201395544</par:MessageId>
<par:Operation>getv</par:Operation>
</par:BasicInfo>
<par:Operation_Name>getv</par:Operation_Name>
</par:Request>
</par:par>
</open:getv>
</soapenv:Body>
</soapenv:Envelope>
为此我尽力而为,但我无法得到它 我试过这样的下面的配置 的的XQuery
<x xmlns="http://ws.apache.org/ns/synapse">
<![CDATA[
declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope";
declare namespace open="http://www.openuri.org/";
{
element {$POS}{
element {$Req_1}{
element {fn:concat(prefix-from-QName(node-name($payload/*[1])),':hh')}{
}
}
}
]]></x>
但我在wso2esb日志中遇到错误,我的代理配置是 的代理
<?xml version="1.0" encoding="UTF-8"?><proxy xmlns="http://ws.apache.org/ns/synapse" name="XQueryPOC" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="LOG" value="LOG"/>
</log>
<log level="full"/>
</inSequence>
<outSequence/>
</target>
<description/>
</proxy>
那么我将如何实现这个使用XQuery。每个请求的命名空间都在变化所以我们需要声明为动态。有些人请帮我这个
先谢谢。
答案 0 :(得分:0)
我已经完成了。通过这种方式,我们可以为各种输入形成上述格式
&LT;
x xmlns="http://ws.apache.org/ns/synapse">
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
declare namespace env="http://eai.im.ii/Envelope";
declare variable $open as xs:string+:="http://www.openuri.org/";
declare variable $ServicePrefix as xs:string+ external;
declare variable $Language as xs:string+ external;
declare variable $sid as xs:string+ external;
declare variable $MessageId as xs:string+ external;
declare variable $uiId as xs:string+ external;
declare variable $Operation as xs:string+ external;
declare variable $Service as xs:string+ external;
declare variable $output as document-node() external;
element{QName($open,concat('open',':',$Operation))}
{
}
}
}
</x>