0

I have the following flow :

 <flow name="SOAPWebService" doc:name="SOAPWebService">

<http:inbound-endpoint address="http://localhost:8088/esb/"   exchange-pattern="request-response" doc:name="HTTP">          
</http:inbound-endpoint>

    <choice doc:name="Choice">
        <when expression="#[payload.contains('c22')]">
            <set-variable variableName="paramCtr" value="#[message.inboundProperties['ctr']]" doc:name="conteneur"/>
            <set-variable variableName="paramC" value="#[message.inboundProperties['c']]" doc:name="critere"/>
            <component class="com.example.components.SampleComponent" doc:name="Java"/>
            <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\MuleStudio\SandBox\resources\PrepareRequestXMLPort.xsl" doc:name="XSLT">
                <mulexml:context-property key="paramCtr" value="#[flowVars['paramCtr']]"/>
                <mulexml:context-property key="paramC" value="#[flowVars['paramC']]"/>
            </mulexml:xslt-transformer>
            <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
            <http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/ClientsDB/port" doc:name="PortWS"/>
        </when>
        <otherwise>
            <set-variable variableName="paramCtr" value="#[message.inboundProperties['ctr']]" doc:name="conteneur"/>
            <set-variable variableName="paramC" value="#[message.inboundProperties['c']]" doc:name="critere"/>
            <component class="com.example.components.SampleComponent" doc:name="Java"/>
            <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\MuleStudio\SandBox\resources\PrepareRequestXMLDouane.xsl" doc:name="XSLT">
                <mulexml:context-property key="paramCtr" value="#[flowVars['paramCtr']]"/>
                <mulexml:context-property key="paramC" value="#[flowVars['paramC']]"/>
            </mulexml:xslt-transformer>
            <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
            <http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/ClientsDB/douane" doc:name="DouaneWS"/>
        </otherwise>
    </choice>


<byte-array-to-string-transformer   doc:name="Byte Array to String" />
    <file:outbound-endpoint path="C:\MuleStudio\SandBox\output" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml " responseTimeout="10000" doc:name="Outgoing File"/>

I want to test if an http request like http://localhost:8088/esb/?type=xxxx&id=1234 if it contains the String xxxx in a way to route the request to the desired web service proxy. I've tried withe the expression expression="#[string.contains['xxxxx']]" but it does not seem to work.

any idea?

thank you.

4

2 回答 2

2

两件事:您需要将“字符串”替换为要执行的属性。消息属性或有效负载等,即#[payload.contains...]。

"contains" 是 java.lang.String 上的 Java 方法,因此您需要使用标准 Java 方法调用与 () 而不是 []。

工作示例:

<choice doc:name="Choice">
    <when expression="#[payload.contains('xxxx')]">

        <logger level="ERROR" message="YES" />
    </when>
    <otherwise>
        <logger level="ERROR" message="NO" />
    </otherwise>
</choice>

或者直接为您的查询参数处理入站属性:

于 2013-05-17T14:01:17.950 回答
1

在您的 http 入站使用 set-variable 将您的查询参数存储到流变量中。然后在您的表达式中使用流变量。

<set-variable value="#[message.inboundProperties['id']]" variableName="paramId"></set-variable>
<set-variable value="#[message.inboundProperties['type']]" variableName="paramType"></set-variable>


or you can directly use inbound property for comparision.

    <when expression="#[message.inboundProperties['type']== 'XXXX']">
于 2013-05-17T14:02:41.760 回答