我想从下面的信封中获取文本,这样我就可以将它作为REST_URL_POSTFIX使用。
我向JMS队列发送一条纯文本消息,下面的WSO2-ESB代理服务被用作JMS队列的接收方/侦听器。我试过以下表达式,但它们不起作用:
$body
$body/text $body/text() SOAP1.1或1.2 body元素。例如,表达式$ body /getQuote引用SOAP主体中的第一个getQuote元素,而不管消息是SOAP-11还是SOAP-12。
和
//信封//正文//文本 //信封//正文//文本()
信息-(发送
LogMediator To: , MessageID: ID:sunnydyal-K55VM-44230-1439804805911-3:2:1:1:9,
Direction: request, @@@@@ Message = ,
Envelope:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<axis2ns8:text xmlns:axis2ns8="http://ws.apache.org/commons/ns/payload">Test</axis2ns8:text>
</soapenv:Body>
</soapenv:Envelope>@代理服务:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JmsToRestProxy"
transports="jms"
statistics="enable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true"/>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
<property name="SOAPAction" scope="default" action="remove"/>
<header name="Action" scope="default" action="remove"/>
<property name="REST_URL_POSTFIX"
expression="//Envelope//Body//text"
scope="axis2"
type="STRING"/>
<switch source="$axis2:HTTP_METHOD">
<case regex="GET">
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
</case>
<case regex="POST">
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
</case>
<default/>
</switch>
<log level="full">
<property name="@@@@@ Message" expression="$body/text"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:8080/Rest/rest" format="rest"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/plain</default>
</rules>
</parameter>
<description/>
</proxy>发布于 2015-08-17 11:37:04
文本节点属于特定名称空间"http://ws.apache.org/commons/ns/payload“:
<log level="full">
<property xmlns:syn="http://ws.apache.org/commons/ns/payload" name="@@@@@ Message" expression="$body/syn:text/text()"/>
</log>发布于 2015-08-17 19:30:21
您可以使用$body variable1获取身体。/text()正在尝试访问不存在的主体的文本元素。
<log level="custom">
<property name="Body" expression="$body" />
</log>1- https://docs.wso2.com/display/ESB481/Synapse+XPath+Variables#SynapseXPathVariables-$body
https://stackoverflow.com/questions/32048524
复制相似问题