我有两个非常相似的 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);
生成代码的代码完全相同。
如有必要,我可以为消息和类型提供标记。我希望匿名化不会弄乱相关部分。
我希望第二个版本也有返回值。我怎样才能做到这一点?