I'm writing my first JAX-WS Web Service. When I'm running my Remote Web Service Client code, I receive the next error:
Here's the code of Remote Web Service Client:Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultExcep tion: Client received SOAP Fault from server:
java.lang.NullPointerException Please see the server log to find more detail regarding exact cause of the failure. at
com.sun.xml.internal.ws.fault.SOAP11Fault.getProto colExcepti on(SOAP11Fault.java:178) at
com.sun.xml.internal.ws.fault.SOAPFaultBuilder.cre ateExcepti on(SOAPFaultBuilder.java:116) at
com.sun.xml.internal.ws.client.sei.StubHandler.rea dResponse( StubHandler.java:238) at
com.sun.xml.internal.ws.db.DatabindingImpl.deseria lizeRespon se(DatabindingImpl.java:189) at
com.sun.xml.internal.ws.db.DatabindingImpl.deseria lizeRespon se(DatabindingImpl.java:276) at
com.sun.xml.internal.ws.client.sei.SyncMethodHandl er.invoke( SyncMethodHandler.java:104) at
com.sun.xml.internal.ws.client.sei.SyncMethodHandl er.invoke( SyncMethodHandler.java:77) at
com.sun.xml.internal.ws.client.sei.SEIStub.invoke( SEIStub.ja va:147) at com.sun.proxy.$Proxy40.getShoes(Unknown Source) at
org.example.shoesshop.client.ShoesServiceClient.ma in(ShoesServiceClient.java:32)
public class ShoesServiceClient { public static void main(String[] args) throws MalformedURLException, ShoesNotFound_Exception{ System.setProperty("com. sun. xml. ws. transport. http. client. HttpTransportPipe. dump", "true"); System.setProperty("com. sun. xml. internal. ws. transport. http. client. HttpTransportPipe. dump", "true"); URL wsdl = new URL("file:///" + new File("").getAbsolutePath() + "/shoesservice.wsdl"); ShoesServiceImpl service = new ShoesService(wsdl).getShoesPort(); service.getShoes(1); // ShoesServiceClient.java:32 is here } }
Also sharing the code of Web Service Publisher
public class ShoesServicePublisher { public static void main(String[] args) { final String addr = "localhost: 8080 /shoesservice"; //with http final Object impl = new ShoesServiceImpl(); Endpoint shoesPub = Endpoint.publish(addr, impl); Scanner sc = new Scanner(System.in); sc.nextLine(); sc.close(); shoesPub.stop(); } }
I use TCP/IP monitor to intercept messages (localhost: 18080 /shoesservice)
The wsdl-file has the next structure (it is stored on my project folder)
<definitions> <types> <xsd:schema> <xsd:import namespace="example. org /ShoesShop" schemaLocation="localhost: 8080 /shoesservice?xsd=1"></xsd:import> </xsd:schema> <xsd:schema> <xsd:import namespace="shoeshop. example /jaxws/shoes" schemaLocation="localhost: 8080 /shoesservice?xsd=2"></xsd:import> </xsd:schema> </types> <message name="getShoes"> <part name="parameters" element="tns:getShoes"></part> </message> <message name="getShoesResponse"> <part name="parameters" element="tns:getShoesResponse"></part> </message> <message name="ShoesNotFound"> <part name="fault" element="tns:ShoesNotFound"></part> </message> <message name="getAllShoes"> <part name="parameters" element="tns:getAllShoes"></part> </message> <message name="getAllShoesResponse"> <part name="parameters" element="tns:getAllShoesResponse"></part> </message> <message name="updateShoes"> <part name="parameters" element="tns:updateShoes"></part> </message> <message name="updateShoesResponse"> <part name="parameters" element="tns:updateShoesResponse"></part> </message> <message name="addShoes"> <part name="parameters" element="tns:addShoes"></part> </message> <message name="addShoesResponse"> <part name="parameters" element="tns:addShoesResponse"></part> </message> <message name="ShoesAlreadyExists"> <part name="fault" element="tns:ShoesAlreadyExists"></part> </message> <message name="deleteShoes"> <part name="parameters" element="tns:deleteShoes"></part> </message> <message name="deleteShoesResponse"> <part name="parameters" element="tns:deleteShoesResponse"></part> </message> <message name="countShoes"> <part name="parameters" element="tns:countShoes"></part> </message> <message name="countShoesResponse"> <part name="parameters" element="tns:countShoesResponse"></part> </message> <portType name="ShoesServiceImpl"> <operation name="getShoes"> <input wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/getShoesRequest" message="tns:getShoes"></input> <output wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/getShoesResponse" message="tns:getShoesResponse"></output> <fault message="tns:ShoesNotFound" name="ShoesNotFound" wsam:Action="shoeshop.example/jaxws/shoes/ShoesServiceImpl/getShoes/Fault/ShoesNotFound"></fault> </operation> <operation name="getAllShoes"> <input wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/getAllShoesRequest" message="tns:getAllShoes"></input> <output wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/getAllShoesResponse" message="tns:getAllShoesResponse"></output> </operation> <operation name="updateShoes"> <input wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/updateShoesRequest" message="tns:updateShoes"></input> <output wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/updateShoesResponse" message="tns:updateShoesResponse"></output> <fault message="tns:ShoesNotFound" name="ShoesNotFound" wsam:Action="shoeshop.example/jaxws/shoes/ShoesServiceImpl/updateShoes/Fault/ShoesNotFound"></fault> </operation> <operation name="addShoes"> <input wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/addShoesRequest" message="tns:addShoes"></input> <output wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/addShoesResponse" message="tns:addShoesResponse"></output> <fault message="tns:ShoesAlreadyExists" name="ShoesAlreadyExists" wsam:Action="shoeshop.example/jaxws/shoes/ShoesServiceImpl/addShoes/Fault/ShoesAlreadyExists"></fault> </operation> <operation name="deleteShoes"> <input wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/deleteShoesRequest" message="tns:deleteShoes"></input> <output wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/deleteShoesResponse" message="tns:deleteShoesResponse"></output> <fault message="tns:ShoesNotFound" name="ShoesNotFound" wsam:Action="shoeshop.example/jaxws/shoes/ShoesServiceImpl/deleteShoes/Fault/ShoesNotFound"></fault> </operation> <operation name="countShoes"> <input wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/countShoesRequest" message="tns:countShoes"></input> <output wsam:Action="shoeshop. example /jaxws/shoes/ShoesServiceImpl/countShoesResponse" message="tns:countShoesResponse"></output> </operation> </portType> <binding name="ShoesPortBinding" type="tns:ShoesServiceImpl"> <soap:binding transport="schemas. xmlsoap. org/soap/http" style="document"></soap:binding> <operation name="getShoes"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> <fault name="ShoesNotFound"> <soap:fault name="ShoesNotFound" use="literal"></soap:fault> </fault> </operation> <operation name="getAllShoes"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> <operation name="updateShoes"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> <fault name="ShoesNotFound"> <soap:fault name="ShoesNotFound" use="literal"></soap:fault> </fault> </operation> <operation name="addShoes"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> <fault name="ShoesAlreadyExists"> <soap:fault name="ShoesAlreadyExists" use="literal"></soap:fault> </fault> </operation> <operation name="deleteShoes"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> <fault name="ShoesNotFound"> <soap:fault name="ShoesNotFound" use="literal"></soap:fault> </fault> </operation> <operation name="countShoes"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> </binding> <service name="Shoes"> <port name="ShoesPort" binding="tns:ShoesPortBinding"> <soap:address location="localhost: 18080/ shoesservice"></soap:address> </port> </service> </definitions>
When I launch the TCP/IP Monitor with running Remote Web Service Client code, I get the next messages in XML format:
Request Message
<?xml version="1.0" standalone="no"?> <S:Envelope xmlns:S="schemas. xmlsoap. org/soap/envelope/"> <S:Body> <ns3:getShoes xmlns:ns2="example.org/ShoesShop" xmlns:ns3="shoeshop.example/jaxws/shoes"> <arg0>1</arg0> </ns3:getShoes> </S:Body> </S:Envelope>
Response Message
<?xml version="1.0" standalone="no"?> <S:Envelope xmlns:S="schemas. xmlsoap. org/soap/envelope/"> <S:Body> <S:Fault xmlns:ns4="w3.org/2003/05/soap-envelope"> <faultcode>S:Server</faultcode> <faultstring>java.lang.NullPointerException</faultstring> </S:Fault> </S:Body> </S:Envelope>
If you need for information, please let me know