首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >WebService方法在请求中始终收到null

WebService方法在请求中始终收到null
EN

Stack Overflow用户
提问于 2011-03-25 21:40:33
回答 1查看 3.1K关注 0票数 0

我有在JBoss上运行的web服务和方法搜索。

代码语言:javascript
运行
复制
@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:

代码语言:javascript
运行
复制
<?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 :(

EN

回答 1

Stack Overflow用户

发布于 2011-03-25 21:47:57

方法中的注释与您在WSDL中为输入消息中的字段名称指定的名称似乎不匹配:

代码语言:javascript
运行
复制
<portType name="MyService">
    <operation name="Search">
        <input message="tns:SearchRequest"/>
        ... 
   </operation>
</portType>
<message name="SearchRequest">
    <part name="searchRequest" element="ans:AvailRQ"/>
</message>

我将尝试查看通过线路发送的实际HTTP流量,以确定SOAP消息中字段的名称。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5433240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档