2013-02-08 56 views
0

我的需求是在mule上發佈兩個具有相同路徑但服務不同的服務。像這樣如何在Mule上發佈兩個具有相同路徑但不同網址的服務3.2

https://localhost:8443/etc/app/version1/Service 

https://localhost:8443/etc/app/version2/Service 

進出口使用上的web.xml servlet映射

<servlet-mapping> 
     <servlet-name>muleServlet</servlet-name> 
    <url-pattern>/app/*</url-pattern> 
</servlet-mapping> 

並試圖用兩種不同的連接器,因爲路徑屬性不允許我使用「VERSION1 /服務」或「版本2 /服務」

<servlet:connector 
    name="conectorVersion1" 
    servletUrl="https://localhost:8443/etc/app/version1/"> 
</servlet:connector> 

<servlet:connector 
    name="conectorVersion2" 
    servletUrl="https://localhost:8443/etc/app/version2/"> 
</servlet:connector> 

最後,端點

<flow 
    name="FlowVersion1" 
    processingStrategy="synchronous"> 

     <servlet:inbound-endpoint 
     connector-ref="conectorVersion1" 
     path="Service"> 
     <-- processors, jaxws-service, interceptors etc.. --> 
     </servlet:inbound-endpoint> 
    </flow> 

    <flow 
    name="FlowVersion2" 
    processingStrategy="synchronous"> 

     <servlet:inbound-endpoint 
     connector-ref="conectorVersion2" 
     path="Service"> 
     <-- processors, jaxws-service, interceptors etc.. --> 
     </servlet:inbound-endpoint> 
    </flow> 

但我得到這個異常:

[[/etc]] StandardWrapper.Throwable: java.lang.IllegalStateException: 
There are at least 2 connectors matching protocol "servlet", so the connector to use must be 
specified on the endpoint using the 'connector' property/attribute. 
Connectors in your configuration that support "servlet" are: conectorVersion1, conectorVersion2, 

在此先感謝。

回答

1

我不認爲聲明兩個servlet連接器是有效的:只有一個servlet上下文,因此一個連接器就足夠了。其實我從來沒有聲明Servlet連接器,因爲默認配置工作得很好。

所以只用了以下配置:

<flow name="FlowVersion1" processingStrategy="synchronous"> 
    <servlet:inbound-endpoint 
     path="version1/Service" /> 
    <set-payload value="version 1" /> 
</flow> 

<flow name="FlowVersion2" processingStrategy="synchronous"> 
    <servlet:inbound-endpoint 
     path="version2/Service" /> 
    <set-payload value="version 2" /> 
</flow> 

我能在servlet容器(碼頭)的部署和我打/{context}/app/version1/Service/{context}/app/version2/Service沒有問題。

+0

謝謝大衛,我已經發現了這一點,它的工作,我即將發佈我的awnser,但現在我只接受你的。我只是對某些事情感到好奇:你知道爲什麼包含下劃線的路徑只能用斜線作爲第一個字符嗎?比如不起作用,但是這個工作正常 – jonfornari 2013-02-08 18:27:27

+0

對我來說這看起來像一個bug:在幕後Mule將端點表示爲URI,並且似乎將'servlet:// service_v1_01_01/Hello'和'servlet:// service_v2_01_01/Hello'視爲衝突,而'servlet:/// service_v1_01_01/Hello'和'servlet:/// service_v2_01_01 /你好'不...打開JIRA:D – 2013-02-08 18:53:42

+0

它是:http://www.mulesoft.org/jira/browse/MULE-6638再次感謝大衛。 – jonfornari 2013-02-08 19:47:08

相關問題