java - 具有多个参数的 CXF Web 服务

标签 java web-services cxf apache-camel

我正在使用 Camel 和 CXF 开发 Web 服务,并使用“代码优先”方法。 对于具有单个参数的方法,一切正常。然而,具有多个参数的方法只接收第一个参数,其他方法解析为空值。不抛出异常。

这是我的路线:

<route>
  <from uri="cxf:bean:serverEndPoint" />
  <log message=">>> data is : ${body}"/>
  <choice>
    <when>
      <simple>${in.header.operationName} == 'doSomething'</simple>
      <to uri="bean:TestWSBean?method=doSomething"/>
    </when>
    ...
</route>

服务器端点定义如下:

<cxf:cxfEndpoint id="serverEndPoint"
               address="http://localhost:9000/casServer/"
               serviceClass="com.test.iface.TestWebService">
  <cxf:inInterceptors>
      <ref bean="loggingInInterceptor"/>
  </cxf:inInterceptors>                   
  <cxf:outInterceptors>
      <ref bean="loggingOutInterceptor"/>
  </cxf:outInterceptors>                   
</cxf:cxfEndpoint>

以及实现 bean 本身:

@WebService
public interface TestWebService {
  public String doSomething(String one, String two);
}

我的问题很基本,应该怎么做才能发送多个参数?

最佳答案

我认为您需要使用 requestwrapper 注释。查看由 cxf 中的 wsdl_first 示例生成的代码。它生成注释和合适的包装类。

@RequestWrapper(localName = "updateCustomer", targetNamespace = "http://customerservice.example.com/", className = "com.example.customerservice.UpdateCustomer")

关于java - 具有多个参数的 CXF Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10114486/

相关文章:

CXF 请求上下文过滤器

java - Apache CXF WSDL2java pom.xml 配置

java - 我如何从 CXF REST 服务类获取上下文路径

java - 如何实现均衡器

java - @SOAPBinding(style = Style.RPC) 用于返回 ArrayList 的 Web 方法

php - 将某些命名空间添加到 PHP 中的 SOAP 信封

c# - 为什么我的系统试图从无效版本的程序集加载类型?

java - 我试图从数组列表中删除所有素数,但没有打印任何内容?

java - Eclipse Java EE 新 Maven 项目 : Could not resolve archetype

java - Android:如何在自己的应用程序中使用 Rsync?