1

我正在尝试使用按照 mule 文档中的教程生成的 Web 服务。已经能够成功构建 Web 服务,但在使用它时遇到问题。我有两个 Java 类“HelloWorld”和“HelloWorldImpl”。这是我的流量

<flow name="helloService" doc:name="helloService">
   <http:inbound-endpoint address="http://localhost:63081/hello" exchange-pattern="request-response" doc:name="HTTP">
       <cxf:jaxws-service serviceClass="com.test.HelloWorld"/>
   </http:inbound-endpoint>
   <component class="com.test.HelloWorldImpl" doc:name="Java"/>
   <cxf:jaxws-client serviceClass="com.test.HelloWorld" operation="sayHi" doc:name="SOAP" />
   <outbound-endpoint address="http://localhost:63081/services/greeter" doc:name="Generic"/>
</flow>

我究竟做错了什么?

当我访问出站端点时,我得到

Cannot bind to address "http://activate.adobe.com:63081/services/greeter" No component     registered on that endpoint
4

4 回答 4

2

您必须让端点接受所有子路径,然后使用消息路由处理错误的子路径:

例子:

<flow name="jfeed_fill_data">
    <http:inbound-endpoint address="http://localhost:1212" />
    <choice>
        <when evaluator="header" expression="INBOUND:http.request.path=/jcore/insert/feed/">
            <component class="main.java.com.joshlabs.jcore.Feed"/>
        </when>
        <otherwise>
            <message-properties-transformer>
                <add-message-property key="http.status" value="404"/>
            </message-properties-transformer>
            <expression-transformer>
                <return-argument evaluator="string" expression="{Exception: &quot;Invalid URL&quot;}"/>
            </expression-transformer>
        </otherwise>
    </choice>
</flow>
于 2013-10-22T12:45:38.307 回答
1

您已经定义了一个在 service end-point 上有一个监听器的流http://localhost:63081/hello。在这个流中请求进来,然后它被转发jaxws-client到另一个正在监听的服务http://localhost:63081/services/greeter

现在错误消息说Cannot bind to address这意味着它不能调用端点。在您尝试向其发送请求的端点的任何地方是否有运行服务?如果您想在本地发送请求,就像您的流程一样,那么您需要另一个流程在该端点进行侦听,类似于您拥有的流程,但具有不同http-endpoint

于 2013-10-22T14:20:52.950 回答
1

第一个问题:如何在本地主机上的同一端口(63081)上运行两个服务。

http://localhost:63081/hello
http://localhost:63081/services/greeter

另外正如您在帖子中提到的,您创建的 Web 服务是带有端点的 Hello 服务

http://localhost:63081/hello

所以你的网络服务应该如下。

<flow name="helloService" doc:name="helloService">
   <http:inbound-endpoint address="http://localhost:63081/hello" exchange-pattern="request-response" doc:name="HTTP">
       <cxf:jaxws-service serviceClass="com.test.HelloWorld"/>
   </http:inbound-endpoint>
   <component class="com.test.HelloWorldImpl" doc:name="Java"/>
</flow>

为了消费,您可以编写另一个具有cxf:jaxws-client

<flow name="helloclient" >
  <some inbound endpoint. >
  ....
   <cxf:jaxws-client serviceClass="com.test.HelloWorld" operation="sayHi" doc:name="SOAP" />
   <outbound-endpoint address="http://localhost:63081/hello" doc:name="Generic"/>
  .....

</flow>

希望这可以帮助。

于 2013-10-22T15:55:52.280 回答
1

您的入站端点是http://localhost:63081/hello您应该调用以使用您的 Web 服务的地址。

此外,您的出站端点似乎指向一个没有 Web 服务可供使用的地址。除非您的 mule 配置中有第二个流程,但您没有显示。

于 2013-10-22T13:22:26.917 回答