This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes Setting  a Connection to 'keep-alive' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Setting  a Connection to Watch "Setting  a Connection to New topic
Author

Setting a Connection to 'keep-alive'

Michael Scott
Ranch Hand

Joined: Jan 20, 2003
Posts: 57
Is there a method in the Java API that can be used to set a connection to 'keep-alive' for a SOAP request message?

Thanks.
Reza Ravasizadeh
Ranch Hand

Joined: Jun 08, 2004
Posts: 177
What do you mean with keeping alive ?


Reza
Michael Scott
Ranch Hand

Joined: Jan 20, 2003
Posts: 57
What I was referring to by 'keep-alive' can be seen in the code in the following link. In the Request SOAP Message, there's a line that says: "Connection: keep-alive".

http://www.coderanch.com/t/221967/Web-Services/java/SAAJ-Invalid-Content-Type-Exception

I have code somewhat similar to that at the above link except that the Request SOAP Message is created using the SOAP API. For example, the connection and message are defined as follows:

------------------------------------------------
SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
SOAPConnection con = scFactory.createConnection();

MessageFactory factory = MessageFactory.newInstance();
message = factory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();

SOAPHeader soapheader = envelope.getHeader();
SOAPBody body = envelope.getBody();

message.setProperty(SOAPMessage.WRITE_XML_DECLARATION,"true");
message.setProperty(javax.xml.soap.SOAPMessage.CHARACTER_SET_ENCODING , "utf-8");
-----------------------------------

My question is whether there is a method in the SOAP API that can set the conection to "keep-alive".

Thanks.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2921
    
    5
Originally posted by Michael Scott:
In the Request SOAP Message, there's a line that says: "Connection: keep-alive".


If you have a closer look you will realize that it is not part of the SOAP envelope but an HTTP header:
Java JDK 1.5: Persistent Connections

The question is: Why do you want to set this? That header is specific to the transport link, there is no guarantee that a proxy would propagate that header.

Given that HTTP is basically a connection-less transport and that ideally a web service should be stateless the motivation for wanting that HTTP header needs to be clarified.
Michael Scott
Ranch Hand

Joined: Jan 20, 2003
Posts: 57
Peer ... thanks very much for the info. I'll have to read up on this matter some more to get a better understanding of what's involved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting a Connection to 'keep-alive'
 
Similar Threads
how chat works in gmail?
friends can any one tell me what is mean by Persistant Http connection
Timing for the Internet connection
Problem in URL Concept(need help urgently)
why would somebody do that??