Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Client received SOAP Fault from server: java.lang.NullPointerException

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Client received SOAP Fault from server: java.lang.NullPointerException

    I'm writing my first JAX-WS Web Service. When I'm running my Remote Web Service Client code, I receive the next error:
    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)
    Here's the code of Remote Web Service Client:
    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

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Client received SOAP Fault from server: java.lang.NullPointerException

    Also posted at: https://www.dreamincode.net/forums/t...nterexception/

    http://www.javaprogrammingforums.com...s-posting.html

    and at: https://coderanch.com/t/735769/java/...P-Fault-server
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 13
    Last Post: August 12th, 2013, 11:20 AM
  2. Replies: 15
    Last Post: July 2nd, 2012, 12:45 PM
  3. Simple Java SOAP client
    By andy in forum Java Networking
    Replies: 3
    Last Post: December 16th, 2010, 04:05 PM
  4. Soap With Attachment AXIS Fault
    By anoopasta in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 23rd, 2010, 11:09 AM
  5. Replies: 0
    Last Post: October 31st, 2010, 08:04 AM

Tags for this Thread