• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Setting a Connection to 'keep-alive'

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean with keeping alive ?
 
Michael Scott
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".

https://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.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic