日期:2014-05-19  浏览次数:20699 次

为什么客户端调用抛出java.lang.NullPointerException异常?
我用axis即时发布了一个简单的webservice,代码是:
public   class   CalcService   {
public   int   add(int   p1,   int   p2)   {
return   p1   +   p2;
}
public   int   subtract(int   p1,   int   p2)   {
return   p1   -   p2;
}
}
输入http://localhost:8080/axis/CalcService.jws?WSDL后能正常看见内容:
<?xml   version= "1.0 "   encoding= "UTF-8 "   ?>  
-   <wsdl:definitions   targetNamespace= "http://localhost:8080/axis/CalcService.jws "   xmlns= "http://schemas.xmlsoap.org/wsdl/ "   xmlns:apachesoap= "http://xml.apache.org/xml-soap "   xmlns:impl= "http://localhost:8080/axis/CalcService.jws "   xmlns:intf= "http://localhost:8080/axis/CalcService.jws "   xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/ "   xmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/ "   xmlns:wsdlsoap= "http://schemas.xmlsoap.org/wsdl/soap/ "   xmlns:xsd= "http://www.w3.org/2001/XMLSchema ">
-   <wsdl:message   name= "subtractResponse ">
    <wsdl:part   name= "subtractReturn "   type= "xsd:int "   />  
    </wsdl:message>
-   <wsdl:message   name= "subtractRequest ">
    <wsdl:part   name= "p1 "   type= "xsd:int "   />  
    <wsdl:part   name= "p2 "   type= "xsd:int "   />  
    </wsdl:message>
-   <wsdl:message   name= "addRequest ">
    <wsdl:part   name= "p1 "   type= "xsd:int "   />  
    <wsdl:part   name= "p2 "   type= "xsd:int "   />  
    </wsdl:message>
-   <wsdl:message   name= "addResponse ">
    <wsdl:part   name= "addReturn "   type= "xsd:int "   />  
    </wsdl:message>
-   <wsdl:portType   name= "CalcService ">
-   <wsdl:operation   name= "add "   parameterOrder= "p1   p2 ">
    <wsdl:input   message= "impl:addRequest "   name= "addRequest "   />  
    <wsdl:output   message= "impl:addResponse "   name= "addResponse "   />  
    </wsdl:operation>
-   <wsdl:operation   name= "subtract "   parameterOrder= "p1   p2 ">
    <wsdl:input   message= "impl:subtractRequest "   name= "subtractRequest "   />  
    <wsdl:output   message= "impl:subtractResponse "   name= "subtractResponse "   />  
    </wsdl:operation>
    </wsdl:portType>
-   <wsdl:binding   name= "CalcServiceSoapBinding "   type= "impl:CalcService ">
    <wsdlsoap:binding   style= "rpc "   transport= "http://schemas.xmlsoap.org/soap/http "   /> &nb