2015-02-10 130 views
-1

我有一個在Tomcat服務器上執行CRUD操作的Spring MVC Web應用程序。我可以在Tomcat之前使用Mule ESB作爲請求處理程序嗎?例如,用戶請求localhost:8181/user/create(Mule ESB端口)和Mule重定向請求到localhost:8080/user/create(Tomcat服務器端口),並通過mule發回響應。我使用Mule ESB進行web服務,但我不明白我如何使用Mule ESB來處理Web應用程序請求。Mule ESB + TOMCAT Web應用程序集成

回答

1

您可以使用3.6發佈了新的HTTP模塊,並使用該流創建一個代理:

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns="http://www.mulesoft.org/schema/mule/core" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:http="http://www.mulesoft.org/schema/mule/http" 
     xsi:schemaLocation=" 
       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:listener-config name="proxyConfig" host="localhost" port="${proxyPort}" /> 
    <http:request-config name="requestConfig" host="localhost" port="${httpPort}" /> 
    <flow name="proxyTemplate"> 
     <http:listener config-ref="proxyConfig" path="/*" responseStreamingMode="AUTO" parseRequest="false" > 
      <http:response-builder statusCode="#[message.inboundProperties['http.status']]" reasonPhrase="#[message.inboundProperties['http.reason']]" /> 
     </http:listener> 

     <copy-properties propertyName="*" /> 
     <remove-property propertyName="http.*" /> 
     <copy-attachments attachmentName="*" /> 

     <set-property propertyName="X-Forwarded-For" value="#[message.inboundProperties['http.remote.address']]" /> 

     <http:request config-ref="requestConfig" method="#[message.inboundProperties['http.method']]" path="#[message.inboundProperties['http.request.path']]" parseResponse="false" > 
      <http:request-builder> 
       <http:query-params expression="#[message.inboundProperties['http.query.params']]" /> 
      </http:request-builder> 
     </http:request> 

     <copy-properties propertyName="*" /> 
     <remove-property propertyName="http.*" /> 
     <copy-attachments attachmentName="*" /> 
    </flow> 

</mule>