Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to set timeout while sending soap request

843833Sep 21 2010 — edited Nov 12 2010
Hi

There is an urgent activity i have to perform...please help

i am trying to call webservice method by making an http connection .i am willing to set time out parameter if i there is no response withing certain time.please help me out to achieve this.

following is the code


System.setProperty("javax.xml.soap.MessageFactory" ,"com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessa geFactory1_1Impl");
System.setProperty("javax.xml.soap.SOAPConnectionF actory","weblogic.wsee.saaj.SOAPConnectionFactoryI mpl");
url = PluginConstants1.CRMWSURL;

messageFactory = MessageFactory.newInstance();
SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = factory.createConnection();
URL endpoint = new URL(url);
//System.out.println(" URL is "+url);
SOAPMessage message = messageFactory.createMessage();
try {
setMessageContent(message, transformXML);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
message.saveChanges();
//This must come before the mime header changes below!

//Need to add a start section to the Content-Type MIME header.
//This allows identification of the start part of this multipart SOAP message
//The value of the start section must match the Content-Id set for the SOAPPart earlier.
String[] mimeHeaders = message.getMimeHeaders().getHeader("Content-Type");
//Assuming there's only one Content-Type header
String headerValue = mimeHeaders[0];
//Add a start part id reference.
headerValue += "; start=\"<startPart>\"";
//Replace existing Content-Type;
message.getMimeHeaders().setHeader("Content-Type", headerValue);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.writeTo(baos);
SOAPMessage response = connection.call(message, endpoint);


ByteArrayOutputStream bao = new ByteArrayOutputStream();
response.writeTo(bao);
responseString = new String(bao.toByteArray());
log.info("CreateOrderBySpecification response:");
log.info(responseString);





please help me out..its very urgent
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2010
Added on Sep 21 2010
1 comment
6,010 views