[英]WebService method always receives null in request
I have the web service running on JBoss with method search. 我在JBoss上使用方法搜索运行了Web服务。
@WebService(serviceName = "MyService", portName = "MyServicePort", name = "MyService", targetNamespace = "http://example.com/MyService", wsdlLocation = "wsdl/myService.wsdl")
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class MyWebServiceBean extends MyService {
@Override
@WebMethod(operationName="Search")
@WebResult(name = "AvailRS")
public AvailRS search(@WebParam(name = "AvailRQ") AvailRQ request) {
return super.search(request);
}
}
myService.wsdl: myService.wsdl:
<?xml version='1.0' encoding='UTF-8'?>
<definitions
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://example.com/MyService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:ans="http://www.example.org/example"
targetNamespace="http://example.com/MyService" name="MyService">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import schemaLocation="wsdl/xsd/AvailRQ.xsd"
namespace="http://www.example.org/example">
</xsd:import>
<xsd:import schemaLocation="wsdl/xsd/AvailRS.xsd"
namespace="http://www.example.org/example">
</xsd:import>
</xsd:schema>
</types>
<message name="SearchRequest">
<part name="searchRequest" element="ans:AvailRQ"/>
</message>
<message name="SearchResponse">
<part name="searchResponse" element="ans:AvailRS"/>
</message>
<portType name="MyService">
<operation name="Search">
<input message="tns:SearchRequest"/>
<output message="tns:SearchResponse"/>
</operation>
</portType>
<binding name="MyServicePortBinding" type="tns:MyService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<operation name="Search">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="MyService">
<port name="MyServicePort" binding="tns:MyServicePortBinding">
<soap:address location="http://localhost:8080/ws/MyService" />
</port>
</service>
</definitions>
Imported xsd are well-styled and don't contain any errors. 导入的xsd格式正确,不包含任何错误。 The problem: when I send a request to my service, I always gets AvailRQ (WebParam) == null.
问题:当我向服务发送请求时,我总是会得到AvailRQ(WebParam)== null。 I've tried generated cliend and SOAP UI.
我已经尝试过生成客户端和SOAP UI。 There're no problems with marshalling/unmarshalling request.
编组/解组请求没有问题。 Just a NullPointer :(
只是一个NullPointer :(
There seems to be a mismatch between the annotation in the method and what the name you have in the WSDL for the name of the field in the input message: 方法中的注释与输入消息中字段名称的WSDL名称之间似乎不匹配:
<portType name="MyService">
<operation name="Search">
<input message="tns:SearchRequest"/>
...
</operation>
</portType>
<message name="SearchRequest">
<part name="searchRequest" element="ans:AvailRQ"/>
</message>
I would attempt to look at the actual HTTP traffic sent across the wire to see what the name of the field in the SOAP message is for sure. 我将尝试查看通过电线发送的实际HTTP流量,以确保可以确定SOAP消息中字段的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.