2016-02-13 59 views
0

我有如下簡單的流程。當我們點擊一​​個流程時,它會觸發另一個流程並獲取http.status 302和Location,這意味着它必須重定向到Location頭域中的位置。但它是拋出異常。我越來越mule 3.5遵循出站端點的重定向

<flow name="httpconnectorFlowRedirection"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" path="redirect" connector-ref="NoSessionEncodingConnector" doc:name="HTTP"/> 
    <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" method="POST" doc:name="HTTP" path="temp" connector-ref="NoSessionEncodingConnector" contentType="text/plain" 
    followRedirects="true" /> 
    <logger message="#[payload]" level="INFO" doc:name="Logger"/> 
</flow> 

<flow name="temp_flow"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" path="temp" connector-ref="NoSessionEncodingConnector" doc:name="HTTP" /> 
    <logger message="in temp flow" level="INFO" doc:name="Logger"/> 
    <set-property propertyName="http.status" value="307" doc:name="Property" /> 
    <set-property propertyName="Location" value="http://localhost:9876/samplehttp" doc:name="Property" /> 
</flow> 

錯誤如下

org.mule.exception.DefaultMessagingExceptionStrategy: 
     ******************************************************************************** 
Message    : Failed to route event via endpoint:  DefaultOutboundEndpoint{endpointUri=http://localhost:9876/temp,  connector=HttpConnector 
{ 
name=NoSessionEncodingConnector 
lifecycle=start 
this=14c5f0c 
numberOfConcurrentTransactedReceivers=4 
createMultipleTransactedReceivers=true 
connected=true 
supportedProtocols=[http] 
serviceOverrides= 
    session.handler=org.mule.session.NullSessionHandler 
} 
    , name='endpoint.http.localhost.9876.temp', mep=REQUEST_RESPONSE,   properties={exceptionOnMessageError=true, http.method=POST,  followRedirects=true, Content-Type=text/plain},  transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is  of type: PostMethod 
Type     : org.mule.api.transport.DispatchException 
Code     : MULE_ERROR--2 
JavaDoc    :  http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/Dispat chException.html 
Payload    : [email protected] 
    ******************************************************************************** 

我收到此錯誤,只有當後續

我使用的騾子3.5重定向設置爲true出站端點。

回答

0

我得到了答案。我需要使用GET reqeust才能成功重定向。 但是,如果我使用http監聽器(因爲mule 3.6),我甚至可以重定向POST請求。考慮下面的例子。

<http:listener-config name="GlobalHTTPConnector" host="localhost" port="9876" doc:name="HTTP Listener Configuration" basePath="mulelearning"/> 
    <flow name="redirection-flow"> 
     <http:listener config-ref="GlobalHTTPConnector" path="/requestredir" doc:name="HTTP"/> 
     <!-- 
      When followRedirects is set to true, when http.status from called service is redirection(eg:301), it redirects to new location. 
      In this case /redFlow1 sends a redirection code 301 and location header. Hence it redirects to /redFlow2 (see the flows below) and gives us the response 'payload from red-flow2' 
     --> 
     <http:request config-ref="HTTP_Request_Configuration" path="/redFlow1" method="POST" followRedirects="true" doc:name="HTTP" /> 
    </flow> 

    <flow name="red-ser1"> 
     <http:listener config-ref="GlobalHTTPConnector" path="/redFlow1" doc:name="HTTP"/> 
     <logger level="INFO" doc:name="Logger" message="I am in red-flow1"/> 
     <set-payload value="payload from red-flow1" /> 
     <set-property propertyName="http.status" value="301" doc:name="Property" /> 
     <set-property propertyName="Location" value="http://localhost:9876/mulelearning/redFlow2" doc:name="Property" /> 
    </flow> 
    <flow name="red-ser2"> 
     <http:listener config-ref="GlobalHTTPConnector" path="/redFlow2" doc:name="HTTP"/> 
     <set-payload value="payload from red-flow2" /> 
     <logger level="INFO" doc:name="Logger" message="I am in red-flow2"/> 
    </flow>