opensubscriber
   Find in this group all groups
 
Unknown more information…

r : rpc-user@xml.apache.org 11 February 2005 • 8:30PM -0500

Re: Cookie Information
by Petr

REPLY TO AUTHOR
 
REPLY TO GROUP




I modified XMLRPC for transport with Apache HttpClient. This
modification can solve all your problems, I think. I didn't share this
modification with others because I didn't test it (and I don't know
how to make diff :) yet thouroghly.

I did it, because used URLConection has some problems and has no
funcionality I need (aborting connection).

some code snippets to help you patch the lib (you need to modify some
other constructors - I deleted them, I'm not going to use them):

your program
---------------------------------------

HttpClient client = new HttpClient();
client.setConnectionTimeout(1000);
PostMethod method = new PostMethod("http://example....");
XmlRpcClient xmlrpc = new XmlRpcClient(client, method);
Vector result = (Vector) xmlrpc.execute("getShowColumns", params);

XmlRpcClient
---------------------------------------

private HttpClient client;
private PostMethod postmethod;
....

public XmlRpcClient(HttpClient client, PostMethod method)
    {
        this.postmethod = method;
    this.client = client;
.....
public Object execute(String method, Vector params)
            throws XmlRpcException, IOException
    {
        Worker worker = getWorker(false);
        try
        {
            Object retval = worker.execute(method, params);
...
Object execute(String method, Vector params)
                throws XmlRpcException, IOException
        {
.....
byte[] request = buffer.toByteArray();

                //URLConnection con = url.openConnection();
                //con.setDoInput(true);
                //con.setDoOutput(true);
                //con.setUseCaches(false);
                //con.setAllowUserInteraction(false);

            postmethod.setRequestHeader("Content-Length",
Integer.toString(request.length));
            postmethod.setRequestHeader("Content-type", "text/xml;
charset=UTF-8");

                if (auth != null)
                {
                    postmethod.setRequestHeader("Authorization",
"Basic " + auth);
                }
            postmethod.setRequestBody(buffer.toString());
            try {
int statusCode = client.executeMethod(postmethod);
if (statusCode == HttpStatus.SC_OK) {
InputStream in = postmethod.getResponseBodyAsStream();
parse(in);
} else {
System.out.println("fetch error");
}
            } catch (IOException ioe) {
            System.out.println(ioe);
            } finally {
            postmethod.releaseConnection();
            }
            }


Hope these changes are ok and it'll help you. I'm using it in
prototype of my program and it works great...

If anyone from XMLRPC lib developers can check this and say if it's
smart enough to get into main tree, or it's stupid change, I will be
glad.

Petr



On Tue, 08 Feb 2005 12:35:23 -0500, Bentzion Schochet
<ben@kill...> wrote:
> Thanks for the response Michael. I will take another look at the source.
>
> Has anyone else had a need to for maintaining session state? Or is the
> standard for this always to pass the sessionid around as a parameter?
>
> I really like the way the Python XMLRPC framework does it where you can
> pass your own Transport implementation to the XMLRPC main class.
>
> Thanks,
> Ben
>
> ----------------------------------------------------
> Make More Sales with http://www.QuickBeep.com
> Never lose a bookmark again with http://KeepTabs.com
> For all your gift giving needs http://SaleCity.com
>
> Blog: http://www.killersite.com
> Skype: callto://ben.schochet
>
>
> -----Original Message-----
> From: Michael Landon - IBN [mailto:mlandon@ibna...]
> Sent: Tuesday, February 08, 2005 10:45 AM
> To: xmlrpc-user@ws.a...; ben@kill...
> Subject: Re: Cookie Information
>
> As of version 1.1, there was no interface for getting/setting HTTP
> header
> info, but a quick look at the source code for the appropriate client
> (XmlRpcClientLite or XmlRpcClient) will show you places where you could
> modify the source & easily get/set header info.
>
> Michael
>
> ----- Original Message -----
> From: "Bentzion Schochet" <ben@kill...>
> To: <xmlrpc-user@ws.a...>
> Sent: Monday, February 07, 2005 8:28 PM
> Subject: Cookie Information
>
> Hi,
> I need to track a session through a cookie header. Is this possible with
> this implementation of XMLRPC? Is there another version in Java that
> will
> allow me access to HTTP header information?
>
> I need to be able to get/set HTTP headers on the XMLRPC traffic (i.e.
> cookies etc.).
>
> Please respond if you have any information on this. I urgently need to
> get
> this working.
>
> Thanks so much,
> Ben
>
>

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

opensubscriber is not affiliated with the authors of this message nor responsible for its content.