1

I am using the below code to send SOAP request to an endpoint. Since we are experiencing some delay in getting the response from server,i would like to set connection timeout in the code.

Code:

SOAPConnectionFactory soapConnectionFactory =SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();   
MimeHeaders header = new MimeHeaders();              
header.addHeader("Content-type", "application/soap+xml;charset=UTF-8");
header.addHeader("SOAPAction", soapAction);
InputStream is = new ByteArrayInputStream(reqXML.getBytes());
SOAPMessage request = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage(header, is);            
SOAPMessage soapResponse = soapConnection.call(request, endPoint);

Can some one help me to modify my code to add the timeout value?

I have gone through thread Setting socket read timeout with javax.xml.soap.SOAPConnection ralted to same issue.I am unable to use the solution provided here as I get failure if I do not specify the soap version while creating soap message.

Community
  • 1
  • 1
Sona Shetty
  • 997
  • 3
  • 18
  • 41

1 Answers1

0

Since, SOAP uses jave.net.URLConnection underneath, you can set the system parameters for connection timeout with is going to be valid for SOAP as well. You can set the following parameters

-Dsun.net.client.defaultConnectTimeout= < timeout>

-Dsun.rmi.transport.proxy.connectTimeout= < timeout>

Iffo
  • 353
  • 7
  • 18