MuleESB - 在运行时为出站连接器更改全局元素值

时间:2017-06-14 14:59:16

标签: mule

我尝试使用Webservice使用者连接器作为出站端点来使用soap服务并尝试动态设置用户名和密码。但我不能用这种方式设定价值。它不解析MEL表达式。我能怎么做 ?谢谢

enter image description here

2 个答案:

答案 0 :(得分:0)

如何在流中设置上游的outboundProperties?您确定您没有尝试使用从Workday连接器传入的inboundProperties吗?这个例子对我有用:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:cluster="http://www.mulesoft.org/schema/mule/ee/cluster"
    xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
    xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd">

    <ws:consumer-config name="Web_Service_Consumer" service="TicketServiceService" port="TicketServicePort" serviceAddress="http://training-u.cloudhub.io/essentials/delta" wsdlLocation="http://mu.mulesoft-training.com/essentials/delta?wsdl" doc:name="Web Service Consumer"/>
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="Copy_of_mydomain1-app-oneFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/soap" doc:name="Copy_of_HTTP"/>
        <set-property propertyName="workday_userid" value="WORKDAY_ID" doc:name="Copy_of_Property"/>
        <set-property propertyName="workday_password" value="WORKDAY-PASSWORD" doc:name="Copy_of_Property"/>
        <ws:consumer config-ref="Web_Service_Consumer" operation="listAllFlights" doc:name="Copy_of_Web Service Consumer"/>
        <logger level="INFO" doc:name="Copy_of_Logger"/>
    </flow>
</mule>

答案 1 :(得分:0)

Add Dataweave before to webservice consumer and put below code in dataweave. It's working.

%dw 1.0
%output application/xml
%namespace wsse http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
%namespace wsu http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
---
wsse#Security: {
wsse#UsernameToken @(Id: 'UsernameToken-18BC1F80151A19D55F14976049846641'): {
wsse#Username: 'john',
wsse#Password @(Type: 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'): 'doe',
wsse#Nonce @(EncodingType: 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'): 'EQDDem3KeXpbud4mJKpLVw==',
wsu#Created: '2017-06-16T09:23:04.662Z'
}
}
}

You can then add the the add property transformer before the webservice consumer (i had added the above as payload, so mapping from payload):

<set-property propertyName="soap.Security" value="#[message.payload]" doc:name="Property"/>

Also, remove the security settings from global web service consumer settings.