【问题标题】:Consuming a Webservice Using Mule 3.4使用 Mule 3.4 使用 Web 服务
【发布时间】:2013-10-31 07:33:15
【问题描述】:

我正在尝试使用按照 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

【问题讨论】:

标签: web-services soap jax-ws cxf mule


【解决方案1】:

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

例子:

<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>

【讨论】:

  • 感谢您的回复,但我实际上正在寻找如何使用 Web 服务并查看输出
【解决方案2】:

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

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

【讨论】:

  • 谢谢,将出站端点更改为localhost:63081/hello,但仍然在浏览器上看到 WSDL_XML,与我构建时的输出相同
【解决方案3】:

您已经定义了一个在服务端点http://localhost:63081/hello 上有一个侦听器的流。在这个流中,请求进来,然后使用jaxws-client 转发到另一个在http://localhost:63081/services/greeter 监听的服务。

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

【讨论】:

  • 感谢您的回答,我创建了另一个带有入站 http-endpoint 的流,地址为 localhost:63081/services/greeter 我要嵌入
  • &lt;cxf:jaxws-server&gt; 因为您使用&lt;jaxws-client&gt; 发送soap 请求,所以您需要一个服务器组件来运行服务
【解决方案4】:

第一个问题:如何在您的本地主机上的同一端口(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>

希望这会有所帮助。

【讨论】:

  • 谢谢,它没有调用另一个服务,我想要简单地实现的是在同一个主机中构建一个服务并使用它
  • 那么 hello 服务应该没有任何其他的 http 出站。使用 Web 服务的一种方法是通过 SOAP UI。别的。如果你想通过 Mule 使用它,那么创建另一个让你 JAXWS:Client 调用 hello 服务的流。
猜你喜欢
  • 2014-02-04
  • 1970-01-01
  • 1970-01-01
  • 2016-04-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多