2013-05-17 2 views
0

나는 다음과 같은 흐름이 있습니다뮬 - 선택 요소로 요청을 얻을하는 HTTP를 테스트

<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"/> 

내가 http://localhost:8088/esb/?type=xxxx&id=1234 같은 HTTP 요청이는 방식으로 문자열 xxxx 포함 된 경우 경우 테스트 할을 요청을 원하는 웹 서비스 프록시로 라우팅합니다. 나는 표현식 expression="#[string.contains['xxxxx']]"을 시도했지만 작동하지 않는 것 같습니다.

어떤 아이디어가 있습니까?

감사합니다.

답변

1

. 그런 다음 표현식에 flow variales를 사용하십시오.

<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']"> 
+0

답변 해 주셔서 감사합니다. 귀하의 첫 번째 해결책을 얻지 못했습니다. 두 번째 것은 출력으로 제공됩니다. [email protected] –

+0

예외는이 선택 라우터와 관련이 없습니다. 로거를 시험해보고,이 예외가 던져지는 곳을 정확하게 보았는가? 전체 흐름을 제공 할 수 있습니까? – user1760178

+0

위의 전체 흐름을 게시했습니다. 감사합니다. –

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> 

또는 직접 검색어 매개 변수에 대한 인바운드 특성을 작동 : 흐름 변수로 검색어 매개 변수를 저장하도록 HTTP 인바운드 사용 설정 변수 후