Hi,
I am using Axis 1.4 and JDK 1.4. I am also facing the same issue where I have to set the timeout. Please find code snippet below.
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
//Custom
SOAPHeaderElement authElement;
SOAPElement authTokenElement;
// Create and populate the body
Name ns = envelope.createName("Authentication", "","urn:test.com");
Name ns1 = envelope.createName("AuthenticationToken", "","urn:test.com");
//Name ns = new
SOAPHeader soaph = envelope.getHeader();
authElement = soaph.addHeaderElement(ns);
authTokenElement = authElement.addChildElement("AuthenticationToken");
authTokenElement.addTextNode( authenticationToken );
SOAPBody body = envelope.getBody();
SOAPElement bodyElement = body.addChildElement(
envelope.createName("GetValue", "", "urn:WS.service.test.com"));
SOAPElement bodyElementMat = bodyElement.addChildElement("First"); // bodyElement.add;
SOAPElement
testing = bodyElementMat.addChildElement("second");
testing.addTextNode("TestData");
envelope = soapPart.getEnvelope();
MimeHeaders headers = message.getMimeHeaders();
headers.addHeader("SOAPAction", "urn:WS.service.test.com/GetValue");
// Save the message
message.saveChanges();
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFactory.createConnection();
--In this thread it is mentioned that the soapconnection was downcasted to soapconnectionImpl, to achieve the timeout
URL url = new URL("http://localhost:8001/ws/services/TestService");
SOAPMessage msg = message;
msg.writeTo(System.out);
SOAPMessage reply = connection.call(msg,url );
//reply.writeTo(System.out); // this is the acutal output of the webservice.
//Getting the values from response
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
if (reply !=null){
Source src = reply.getSOAPPart().getContent();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(src, result);
}
System.out.println("finally"+writer.toString());
}
In this thread it is mentioned that the soapconnection was downcasted to soapconnectionImpl, to achieve the timeout. Could you please provide your suggestions. Any suggestion is highly appreciated.
Thanks in Advance.