我正在尝试使用 JAX-WS 从我的 Java 代码生成 WSDL。
除了我在 WSDL 中的操作,soapAction 仍然为空之外,一切似乎都正常。
这是我的代码:
@WebService
public class MyClass {
public MyStuff queryStuff(String myParam) {
return null;
}
}
生成的 WSDL 包含以下内容:
<wsdl:operation name="queryStuff">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="queryStuffRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="queryStuffResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
我不知道我做错了什么。有什么想法吗?
最佳答案
您需要使用 @WebMehtod
注释您的方法。
示例
@WebService(name = "dataService", targetNamespace = "http://example.com/vap/webservice/dataservice/definition")
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL, parameterStyle = ParameterStyle.WRAPPED)
public interface DataSEI {
@WebMethod(action = "createAction", operationName = "create")
DataTransferObjectStatusContainer create(
@WebParam(name = "objects", targetNamespace = "http://example.com/vap/webservice/dataservice/definition")
DataTranferObjectContainer pObjectsContainer,
@WebParam(name = "atomic", targetNamespace = "http://example.com/vap/webservice/dataservice/definition")
boolean pAsAtomicOperation) throws Fault;
}
注意:示例中的许多注释不是必需的,但我将其放在那里是为了向您展示使用 JAX-WS 可以做的所有事情
关于java - 生成的 WSDL 中的空 soapAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11466234/