You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Yadav, Ashok" <AY...@carreker.com> on 2005/03/11 03:05:25 UTC

SOAPConnection Timeout

Hi All
I am working on Message-style web service. To communicate with webservice I
am sending SOAP Message with attachments. It works fine excepts the client
is getting timed out after 60 seconds. I am using SOAPConnection to connect
to web Service which doesn't support time out function. Is there any way
through which I can set timeout value. Here is the sample of the client
code.

Thanks
Mike Chouffani

	    SOAPConnection con =
SOAPConnectionFactory.newInstance().createConnection();
	    SOAPFactory elementFactory = SOAPFactory.newInstance();
	    MessageFactory mf = MessageFactory.newInstance();
	    SOAPMessage msg = mf.createMessage();
	    SOAPPart soapPart = msg.getSOAPPart();
	    SOAPEnvelope envelope = soapPart.getEnvelope();
	    SOAPBody body = envelope.getBody();
	    document = null;
	    
	    DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
          factory.setNamespaceAware(true);
	    DocumentBuilder builder = factory.newDocumentBuilder();
	    document = builder.parse( new
File("C:/temp/FILE_STORAGE_LOCATION/xml2go.xml")); 
	   
	    DOMSource domSource = new DOMSource(document);
	    soapPart.setContent(domSource);

		
	    try{
	
AttachImage2Message(msg,"file:///temp/FILE_STORAGE_LOCATION/2004190101234555
44_FBW_IN.tiff");
	    System.out.println("Successfull Associateion of Images to SOAP
Message");
	    msg.saveChanges();
	    }
	    catch(Exception _exception)
		{
	    	System.out.println("Unsuccessfull Associateion of Images to
SOAP Message");
		}
	    URL endpoint = new URL(
"http://localhost:8080/transalator/services/MessageService" );
	    System.out.println( "\nSending message to URL: " +
endpoint.toString() );
	    SOAPMessage reply = null;
	    
	    try
		{
	    reply = con.call( msg, endpoint );
	    
		}
	    catch( Exception ex)
		{
	    	String errmsg = ex.toString();
	    } 

public static void AttachImage2Message(SOAPMessage sndMessage,String
imagePath)
	{
		try
		{
		URL imageUrl= new URL(imagePath);
		AttachmentPart imageAttachment =
sndMessage.createAttachmentPart( new DataHandler(imageUrl) );
		imageAttachment.setContentType("image/jpeg" );
		sndMessage.addAttachmentPart( imageAttachment);
		sndMessage.saveChanges();
		}
		catch(Exception ex)
		{
			
		}
	}