2011-03-25 19 views
0

我有通過方法搜索在JBoss上運行的Web服務。WebService方法在請求中總是接收空值

@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。 我試過生成cliend和SOAP UI。 編組/解組請求沒有問題。 只是一個空指針:(

+0

什麼是'wsdl/xsd/AvailRS.xsd'和'wsdl/xsd/AvailRQ.xsd'? – 2011-03-25 13:53:00

回答

0

似乎是在方法的註釋和你的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消息中字段的名稱是肯定的。

+0

我試過 '@WebParam(name =「searchRequest」)'和 '@WebParam(name =「S earchRequest「),但它仍然不起作用。 – ninja 2011-03-25 14:36:12

相關問題