如何通过Mule ESB中的单个http:inbound-endpoint公开多个cxf:jaxws-service

时间:2012-04-17 11:29:14

标签: cxf esb mule endpoint

我正尝试根据此配置通过mule中的单个端点公开多个服务接口: 每个服务接口都有一个略有不同的URL (1)http://localhost/services/Login (2)http://localhost/services/Admin

但是我收到了错误 “Soap 1.1端点已在地址上注册”

有关如何执行此操作的任何提示?我只想使用cxf服务在SOAP和Java之间进行编组/解组,并在以后提供ws-security。

<flow name="flow_Services">
    <http:inbound-endpoint address="http://localhost/services" exchange-pattern="request-response">

    <choice>
        <when expression="inbound:http.request=/services/Login" evaluator="header">
            <cxf:jaxws-service serviceClass="com.ws.client.generated.Login" />
            <component><spring-object bean="Login"/></component>
        </when>

        <when expression="inbound:http.request=/services/Admin" evaluator="header">
            <cxf:jaxws-service serviceClass="com.ws.client.generated.Admin" />
            <component><spring-object bean="Admin"/></component>
        </when>
    </choice>

1 个答案:

答案 0 :(得分:1)

您可以拥有多个具有相同主机名和端口的http入站端点,但路径不同。这是我测试的一个简单示例:

<flow name="Flow" doc:name="EchoFlow">
    <http:inbound-endpoint exchange-pattern="request-response" 
         host="localhost" port="8084" path="services/hello" />
    <cxf:jaxws-service port="80" serviceClass="mypackage.ServiceInterface" />
    <component class="mypackage.ServiceClass" />
</flow>
<flow name="Flow2" doc:name="EchoFlow2">
    <http:inbound-endpoint exchange-pattern="request-response" 
         host="localhost" port="8084" path="services/goodbye" />
    <cxf:jaxws-service port="80" serviceClass="mypackage.ServiceInterfaceTwo" />
    <component class="mypackage.ServiceClassTwo" />
</flow>

我们在这里托管两个网络服务;两个端点URL都以

开头
http://localhost:8084/services/ 

但有不同的结局(你好和再见)。 ServiceInterface类如下所示:

package mypackage;
import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface ServiceInterface {
    @WebMethod
    String sayHello(String name);
}

ServiceClass看起来像这样:

package mypackage;
import javax.jws.WebService;

@WebService(endpointInterface = "mypackage.ServiceInterface")
public class ServiceClass implements ServiceInterface {
    public String sayHello(String name) {
        return "Hello "+name;
    } 
}

ServiceInterfaceTwo和ServiceClassTwo是相同的,但它没有sayHello(),而是说了Goodbye()。