Hi,

I have a servlet running on Tomcat which returns a SOAP message from its
doPost() method.
I am trying to connect to the servlet using the point to point
request-response messaging
mechanism. I have written a java client for this. 

The problem I face is, that the client connects to the servlet once and
I get the soap message returned
by the servlet. If I run the client a second time I get the following
exception :

javax.xml.soap.SOAPException: java.net.SocketException: Connection reset
by peer
        at
org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:92)
        at MyRequestClient.main(KiveraRequest.java:42)

If I restart TOMCAT and run the client again, it works again once.

My client code looks like this :

            SOAPConnectionFactory scf =
SOAPConnectionFactory.newInstance();
            SOAPConnection con = scf.createConnection();

            MessageFactory mf = MessageFactory.newInstance();
            SOAPMessage msg = mf.createMessage();

            // Access the SOABBody object
            SOAPPart part = msg.getSOAPPart();
            SOAPEnvelope envelope = part.getEnvelope();
            SOAPBody body = envelope.getBody();

            //create SOAPBodyElement request
            Name bodyName = envelope.createName("request-data");
            SOAPBodyElement requestData = body.addBodyElement(bodyName);
  
            Name requestName = envelope.createName("request");
            SOAPElement request =
                  requestData.addChildElement(requestName);
            request.addTextNode("Send data.");
            msg.saveChanges();

            //create the endpoint and send the message
            URL endpoint = new
URL("http://localhost:8888/MyWebService/servlet/MyServlet";)
;
            SOAPMessage response = con.call(msg, endpoint);
            con.close();

Is this because the connection.close() call is'nt working ? Does anybody
know how the connection mechanism
works ? Does'nt the client open a new connection to the servlet each
time its run ?

Any information will be greatly appreciated.

Thanks a lot,
kevin.

Reply via email to