【问题标题】:Camel exposing CXF Web serviceCamel 暴露 CXF Web 服务
【发布时间】:2016-02-11 14:21:20
【问题描述】:


我正在尝试使用 Camel 公开一个 JAX-WS Webservice(一个带注释的 Java 类)。使用单个参数时,Web 服务会正确回复。另一方面,当使用对象或多个参数作为参数时,它不起作用。 这是我在 JBoss Fuse 上部署的蓝图:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:cxf="http://cxf.apache.org/blueprint/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd              http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd              http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd              http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
   <camelcxf:cxfEndpoint id="demo-target-cxf" address="http://localhost:9000/SourceExample/hello" serviceClass="com.sample.SourceExampleWSImpl" endpointName="SourceExamplePort" serviceName="SourceExampleService" />
   <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="fuse-demo-route-exmple-cxf">
      <route id="demo-target-cxf">
         <from uri="cxf:bean:demo-target-cxf" />
         <transform>
            <simple>${in.body}</simple>
         </transform>
         <log message="Message input: ${in.body}" />
         <removeHeaders pattern="CamelHttp*" />
      </route>
   </camelContext>
</blueprint>

这里是Web Service的实现类:

@WebService

public class SourceExampleWSImpl {


@WebMethod
    public int getTotal(int x, int y) {
        return x+y;
    }

}

捆绑 ic 正确部署在 JBoss Fuse 上。调用 Web 服务时,只计算第一个参数。例如,使用参数 1 和 4 调用:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://sample.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <sam:getTotal>
         <arg0>1</arg0>
         <arg1>4</arg1>
      </sam:getTotal>
   </soapenv:Body>
</soapenv:Envelope>

返回:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getTotalResponse xmlns:ns2="http://sample.com/">
         <return>1</return>
      </ns2:getTotalResponse>
   </soap:Body>
</soap:Envelope>

知道如何解决吗? 谢谢

【问题讨论】:

  • 尝试将@WebParam 用于getTotal 中的参数。不知道能不能解决。
  • 谢谢,但没有解决问题。

标签: apache-camel jbossfuse


【解决方案1】:

你的意思是预期的输出应该是

1 + 4 = 5 因为应该调用下面的代码?

 public int getTotal(int x, int y) {
        return x+y;
    }

如果没有发生这种情况,当您使用camel-cxf 作为bean 时,bean 只定义了合约,实现中的代码没有在使用中。

如果您只想要一个标准的 SOAP-WS 并编写构建和处理 SOAP 请求/响应的 java 代码,那么只需使用普通的 CXF。

【讨论】:

  • 非常感谢克劳斯的回复。我将进行一些检查并提供一些反馈。问候
猜你喜欢
  • 1970-01-01
  • 2019-07-22
  • 2016-12-31
  • 2012-12-02
  • 1970-01-01
  • 2019-07-27
  • 2019-01-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多