4

我有两个非常相似的 wsdl 文件,它们生成不同的 Java 代码。在第一种情况下,我得到一个带有@WebMethod-annotation 和返回值的方法,在第二种情况下,我得到一个带有@ResponseWrapper-annotation 的方法并且没有生成返回值。我想要返回值。

1.服务1

<wsdl:operation name="foo">
        <wsdl:input  name="deleteUser"         message="tns:deleteUserRequest"/>
        <wsdl:output name="deleteUserResponse"  message="tns:deleteUserResponse"/>
        <wsdl:fault name="ServiceFault"        message="tns:ServiceFault"/>
    </wsdl:operation> 

生成:

    @WebMethod
@WebResult(name = "commonReturnType", targetNamespace = "http://www.foo.com/fooSchemaTypes-v3.0/", partName = "returnValue")
public CommonReturnType foo(
    @WebParam(name = "fooType", targetNamespace = "http://www.foo.com/fooSchemaTypes-v3.0/", partName = "user")
    FooType user)
    throws ServiceFault
;

2. FooBarService

    <wsdl:operation name="fooBar">
        <wsdl:input name="fooBar" message="tns:fooBarRequest"></wsdl:input>
        <wsdl:output name="ackFileResponse" message="tns:fooBarResponse"></wsdl:output>
        <wsdl:fault name="ServiceFault" message="tns:fooBarFault"></wsdl:fault>
    </wsdl:operation>

产生:

  @WebMethod
@RequestWrapper(localName = "fooBar", targetNamespace = "http://www.foo.com/fooBarSchemaTypes-v1.0/", className = "com.foo.fooBar.v1_0.GetFileType")
@ResponseWrapper(localName = "fooBarResponse", targetNamespace = "http://www.foo.com/fooBarSchemaTypes-v1.0/", className = "com.foo.fooBar.v1_0.CommonReturnType")
public void ackFile(
    @WebParam(name = "id", targetNamespace = "")
    String id,
    @WebParam(name = "timestamp", targetNamespace = "")
    XMLGregorianCalendar timestamp,
    @WebParam(name = "anotherId", targetNamespace = "")
    String anotherId,
    @WebParam(name = "fileId", targetNamespace = "")
    String fileId,
    @WebParam(name = "returnCode", targetNamespace = "", mode = WebParam.Mode.OUT)
    Holder<ReturnCode> returnCode,
    @WebParam(name = "errorMessage", targetNamespace = "", mode = WebParam.Mode.OUT)
    Holder<String> errorMessage);

生成代码的代码完全相同。

如有必要,我可以为消息和类型提供标记。我希望匿名化不会弄乱相关部分。

我希望第二个版本也有返回值。我怎样才能做到这一点?

4

1 回答 1

4

这有帮助(仍然不明白,为什么在案例 2 中这是必要的,而在案例 1 中则没有必要):

<!--JAX-WD Customization: disable wrapper style rules
  see also: http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/2.0/jaxws/customizations.html#2.2_Wrapper_Style
-->
<jaxws:bindings wsdlLocation="v1.0/dxpInsurerServiceV1.0.wsdl" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
 <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>

在 jaxws-custom.xml 中

这是在生成蚂蚁任务中:

另请参阅: wsimport 不使用复杂的输入类型

于 2012-06-27T06:06:46.723 回答