【问题标题】:Consuming a webservice with CXF in Mule 3.5在 Mule 3.5 中使用 CXF 使用 Web 服务
【发布时间】:2016-04-01 12:16:24
【问题描述】:

我正在尝试使用 mule(Anypoint Studio) 中的 CXF 组件使用 Web 服务。 所以我尝试从 URL 生成 WSDL 文件,但我得到了这个错误:Rpc/encoded wsdls are not supported in CXF 所以我关注了this answer.

它工作并生成了客户端存根,然后将文件复制到我的 mule 项目中。

但我收到此错误:

Service.SomeService.<init>(java.net.URL, javax.xml.namespace.QName) (java.lang.NoSuchMethodException)

这是我的流程:

<flow name="WebServiceTest">
          <cxf:jaxws-client
         clientClass="service.SomeService"
         wsdlLocation="http://127.0.0.1:8000/api/v2_soap/?wsdl"
        operation="test"/>         
      <outbound-endpoint address="http://127.0.0.1:8000/api.php/?type=v2_soap"/>
</flow>

有什么想法吗?

【问题讨论】:

    标签: java web-services mule cxf anypoint-studio


    【解决方案1】:

    您的配置不正确,特别是您的出站端点 url。 您可以尝试按照 Mule 文档配置 CXF 客户端。
    您还可以为您的 JAX-WS 服务构建客户端,而无需从 WSDL 生成客户端。在这里,您需要一份服务接口和所有本地数据对象的副本才能使用类似这样的内容:-

    <flow name="csvPublisher">
      ...
      <cxf:jaxws-client serviceClass="org.example.HelloService" operation="sayHi"/>
      <outbound-endpoint address="http://localhost:63081/services/greeter"/>
    </flow>
    

    另一种方法是您可以使用 CXF 生成的客户端作为出站端点。首先,您需要使用 CXF 中的 WSDL to Java 工具或 Maven 插件生成一个 CXF 客户端。
    然后你需要配置如下内容:-

    <flow name="csvPublisher">
      ...
      <cxf:jaxws-client
             clientClass="org.apache.hello_world_soap_http.SOAPService"
             port="SoapPort"
             wsdlLocation="classpath:/wsdl/hello_world.wsdl"
             operation="greetMe"/>
      <outbound-endpoint address="http://localhost:63081/services/greeter"/>
    </flow>
    

    最好将 wsdl 放在本地类路径中。

    请在此处查看完整文档作为参考以进行配置:-
    https://docs.mulesoft.com/mule-user-guide/v/3.7/consuming-web-services-with-cxf

    Consuming a Webservice Using Mule 3.4

    【讨论】:

    • 感谢您的回答!很抱歉,我没有明确说明我必须从 WSDL 生成,所以你建议的“另一种方法”对我来说不是“不支持 cxf”,还有其他想法吗?
    猜你喜欢
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-22
    • 2014-10-03
    • 2011-02-23
    相关资源
    最近更新 更多