You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Rich Johns <rj...@vignette.com> on 2001/04/12 00:09:48 UTC

Headers, Call, SOAPHttpConnection

There doesn't seem to be a way to set headers from the
client. The way session management is currently implemented
forces the client to hang on and keep track of a SOAPHttpConnection
instance that is configured to maintainSession.

Why not just allow the client to get and set headers, ie., a Hashtable,
on the Call object and then have Call:invoke() pass in the headers to
the SOAPHttpConnection:send() method?

Let the client get the headers and pick out the Session cookies if it
wants to. It's easier to cache a cookie than it is to cache an instance
of SOAPHttpConnection.

Here's what I'd like to do as a client:

Call call = new Call(); //first time call
//... config call
Response resp = call.invoke();
Headers headers = call.getHeaders();
findAndCacheSessionId( headers );

Call call2 = new Call(); //subsequent call in same session
//... config call
HashTable headers = new HashTable();
getSessionIdAndPutInHeader( headers); //note I could put any headers I wanted, not just session
call.setHeaders( headers );
resp = call.invoke(...)

// inside Call:invoke() it would pass headers to SOAPHttpConnection
st.send(url, SOAPActionURI, getHeaders(), callEnv, smr, ctx);

That's it! Am I thinking about this incorrectly? (If so, my humble apologies and please correct me).

As an alternative, since there already is a way to get headers via the call
by doing a call.getSOAPTransport().getHeaders(), you could just have
the Call:invoke() method take an additional HashTable arg (headers) that it would
turn around and use in its call to SOAPHttpConnection:send() method.

Yet another alternative, you could implement a setHeaders() method on
SOAPHttpConnection (which already has a getHeaders() method ).
This would allow the client to do a call.getSoapTransport() which
will be an instance of SOAPHttpConnection. It can then set the headers
on it.
Then, in the SOAPHttpConnection:send() method, have it examine
it's own data member, ie.,  requestHeaders_  which may or may not have been
set by the client, if null it would create a new HashTable for the headers and
continue on it's merry way. As it is now, the SOAPHttpConnection:send() method
takes a 'HashTable headers' arg, but there's no way to pass headers in.

I think I prefer choice 1 as it seems most flexible. What do you think?