如何告诉cxf在方法中保留包装器类型? [英] How to tell cxf to keep the wrapper types in methods?

查看:99
本文介绍了如何告诉cxf在方法中保留包装器类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的WSDL中,我有一个操作

In my WSDL I have an operation

<wsdl:operation name="theMethod">
    <wsdl:input message="input1" name="input1"></wsdl:input>
    <wsdl:output message="tns:classNumber1" name="classNumber1"></wsdl:output>
</wsdl:operation>

在我的xsd中, classNumber1 是一个复杂的类型,它是另一种类型的包装:classNumber2

in my xsd, classNumber1 is a complex type and it is a wrapper for another type: classNumber2

<xs:complexType name="classNumber1">
  <xs:sequence>
   <xs:element minOccurs="0" name="arg0" type="tns:classNumber2"/>
  </xs:sequence>
</xs:complexType>

当我使用cxf生成类时(我使用cxf maven插件),我预计 theMethod 返回 ClassNumber1 ,但它是 ClassNumber2

when I generate classes with cxf (I use cxf maven plugin), I expected that theMethod to return a ClassNumber1 but it was a ClassNumber2.

@WebMethod
@ResponseWrapper(localName="classNumber1" , className="com.model.ClassNumber")
public ClassNumber2 theMethod (Input1 input1){
    ...
}

有没有一种告诉cxf使用包装器CLassNumber1生成方法的方法。
谢谢。

Is there a way to tell cxf to generate the method with the wrapper CLassNumber1. Thanks.

推荐答案

我在 doc ,问题如何将生成的Web服务方法调用从包装器样式切换到非包装器样式(或副-versa)?

保持包装器生成cxf的解决方案是在pom.xml中添加绑定文件

The solution to keep wrappers with cxf generation is to add a binding file in the pom.xml:

<defaultOptions>
<bindingFiles>
    <bindingFile>${basedir}/src/main/resources/bindings.xjb</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
</defaultOptions>

在绑定文件中,您将 enableWrapperStyle 设置为false:

In the binding file you set enableWrapperStyle to false:

<jaxws:bindings
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns="http://java.sun.com/xml/ns/jaxws"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
    <enableWrapperStyle>false</enableWrapperStyle>
</jaxws:bindings>

这篇关于如何告诉cxf在方法中保留包装器类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆