我有在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:
<?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>
导入的xsd具有良好的样式,不包含任何错误。问题:当我向我的服务发送请求时,我总是得到AvailRQ (WebParam) == null。我尝试过生成客户端和SOAP UI。编组/解组请求没有问题。只有一个NullPointer :(
发布于 2011-03-25 13:47:57
方法中的注释与您在WSDL中为输入消息中的字段名称指定的名称似乎不匹配:
<portType name="MyService">
<operation name="Search">
<input message="tns:SearchRequest"/>
...
</operation>
</portType>
<message name="SearchRequest">
<part name="searchRequest" element="ans:AvailRQ"/>
</message>
我将尝试查看通过线路发送的实际HTTP流量,以确定SOAP消息中字段的名称。
https://stackoverflow.com/questions/5433240
复制相似问题