我有两个非常相似的wsdl文件,它们生成不同的Java代码。在第一种情况下,我得到一个带有@WebMethod-annotation和返回值的方法,在第二种情况下,我得到一个带有@ ResponseWrapper-annotation的方法,并且不生成返回值。我想要返回值。
<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
;
<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>
genereates:
@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);
生成代码的代码完全相同。
如有必要,我可以为消息和类型提供标记。我希望匿名化并没有弄乱相关部分。
我希望第二个版本也带有返回值。我怎样才能做到这一点?
答案 0 :(得分: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
中这是在生成ant-task: