简体   繁体   中英

Mule - Get SOAP operation with MEL

This is my mule flow:

HTTP Listener -> Logger -> WS:Consumer -> Logger

<flow name="ClientFlow" >
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
    <logger level="INFO" doc:name="Logger" message="#[message.payloadAs(java.lang.String)]"/>
    <ws:consumer config-ref="Web_Service_Consumer" doc:name="Web Service Consumer" operation="NewRequestTest"/>
    <logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>

</flow>

I send a SOAP message to my mule flow with SOAPUI :

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<NewRequestTest xmlns="urn:microsoft-dynamics-schemas/codeunit/Requests">
<xmlEntry>
<NewRequestTest>
<hiMessage>Hi</hiMessage>
<NewRequestTest>
</xmlEntry>
</NewRequestTest>
</soapenv:Body>
</soapenv:Envelope>

I want to do the operation from the ws:consumer dynamically getting from the SOAP header with a MEL expression .

In what way it would be possible to obtain that information?

You can just use the xpath3 function if your operation is specified somewhere in the body of the request, in this way:

<set-variable variableName="operation" value="#[xpath('//theTagcontainingwhatyouwant')]" doc:name="Variable"/>
<ws:consumer config-ref="Web_Service_Consumer" doc:name="Web Service Consumer" operation="#[flowVars['operation']]"/>

Please note that in theory you could take the operation also from the SOAP-Action header that normally comes along with a soap request, you can access it via inboundProperties

#[message.inboundProperties['SOAPAction']]

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM