• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting a Connection to 'keep-alive'

 
Michael Scott
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean with keeping alive ?
 
Michael Scott
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic