*/
public HttpSessionCookie getSessionCookie()
{
if (getConfiguration() == null)
{
throw new ChainedRuntimeException("setConfiguration() should have "
+ "been called prior to calling getSessionCookie()");
}
HttpClientConnectionHelper helper =
new HttpClientConnectionHelper(
((WebConfiguration) getConfiguration()).getRedirectorURL(this));
WebRequestImpl obtainSessionIdRequest = new WebRequestImpl(
(WebConfiguration) getConfiguration());
//Not sure whether I should be adding the service parameter to
//this request (this) or to the obtainSessionIdRequest
//seems obvious that it should be the obtainSessionIdRequest
RequestDirectives directives =
new RequestDirectives(obtainSessionIdRequest);
directives.setService(ServiceEnumeration.CREATE_SESSION_SERVICE);
HttpURLConnection resultConnection;
try
{
resultConnection =
helper.connect(obtainSessionIdRequest, getConfiguration());
}
catch (Throwable e)
{
throw new ChainedRuntimeException("Failed to connect to ["
+ ((WebConfiguration) getConfiguration()).getRedirectorURL(this)
+ "]", e);
}
WebResponse response;
try
{
response = (WebResponse) new WebResponseObjectFactory(
resultConnection).getResponseObject(
WebResponse.class.getName(),
obtainSessionIdRequest);
}
catch (ClientException e)
{
throw new ChainedRuntimeException("Failed to connect to ["
+ ((WebConfiguration) getConfiguration()).getRedirectorURL(this)
+ "]", e);
}
Cookie cookie = response.getCookieIgnoreCase("jsessionid");