You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by li...@jimisola.com on 2005/10/20 15:28:50 UTC
[PATCH]Patches and additions to make HttpClient work with Apache XML-RPC
Hi!
I've made some additions/changes to get Commons HttpClient working correctly
with Apache XML-RPC which I think can be helpful for others as well.
1) Updated the CommonsXmlRpcTransport class (which I think should be renamed
CommonsHttpClientXmlRpcTransport)
2) Added a new factory class (CommonsHttpClientXmlRpcTransportFactory). The
factory class can have default values set for url, basic auth, (read) timeout
and connection factory class. Setting these will cause the
CommonsXmlRpcTransport created using createTransport to have these default
setting.
I've have add different versions of constructors for convenice (e.g. URL vs
host
+ port, auth vs username + password). I am not familiar on whether you like
these or not - feel free to remove some of them.
Attached file are:
- the brand new factory class CommonsHttpClientXmlRpcTransportFactory
- the updated CommonsXmlRpcTransport (I moved some instance variable
declarations so that they're all together)
- a diff -u version of CommonsXmlRpcTransport (NOTE: I just realized that I
did
not do the diff against CVS version - it's against the 2.0 version. If this is
a
problem let me know.)
Regards,
Jimisola
BACKGROUND
I could not get the XML-RPC library to work with HttpClient.
My code:
XmlRpcClient xmlRpcClient = new XmlRpcClient(new
URL("http://localhost:8080/RPC2"),
DefaultXmlRpcTransportFactory.createTransportFactory("org.apache.xmlrpc.DefaultXmlRpcTransportFactory",
new Properties()));
causes the following exception to be thrown:
Exception in thread "main" org.apache.xmlrpc.XmlRpcClientException: Transport
Factory constructor not found:
org.apache.xmlrpc.DefaultXmlRpcTransportFactory(java.util.Properties
properties)
at
org.apache.xmlrpc.DefaultXmlRpcTransportFactory.createTransportFactory(DefaultXmlRpcTransportFactory.java:104)
at other._TestXmlRpcTimeoutClient.main(_TestXmlRpcTimeoutClient.java:31)
Caused by: java.lang.NoSuchMethodException:
org.apache.xmlrpc.DefaultXmlRpcTransportFactory.<init>(java.util.Properties)
at java.lang.Class.getConstructor0(Class.java:1937)
at java.lang.Class.getConstructor(Class.java:1027)
at
org.apache.xmlrpc.DefaultXmlRpcTransportFactory.createTransportFactory(DefaultXmlRpcTransportFactory.java:82)
.. 1 more
Reason:
org.apache.xmlrpc.DefaultXmlRpcTransportFactory does not have a constructor
with
signature:
Class [] CONSTRUCTOR_SIGNATURE = new Class [] { Properties.class };
I've followed the code from beginning and as far as I can see the code can't
work with Commons HttpClient due to 1) missing constructor and 2)
CommonsXmlRpcTransport is NOT USED ANYWHERE.
1. XmlRpcClient(URL, XmlRpcTransportFactory)
2. XmlRpcTransPortFactory: SunSSLTransportFactory,
DefaultXmlRpcTransportFactory
3. DefaultXmlRpcTransportFactory: does not refer to CommonsXmlRpcTransport and
seems to be missing proper constuctor (see exception above)
Re: [PATCH]Patches and additions to make HttpClient work with Apache XML-RPC
Posted by Henri Gomez <he...@gmail.com>.
Well you could plug your own CommonsHttpClient to handle XML-RPC posts
so that's why the class is alone
2005/10/21, Jimisola Laursen <li...@jimisola.com>:
> ----- Original Message -----
> From: "Jochen Wiedmann" <jo...@gmail.com>
> To: <xm...@ws.apache.org>
> Sent: Friday, October 21, 2005 9:35 PM
> Subject: Re: [PATCH]Patches and additions to make HttpClient work with
> Apache XML-RPC
>
>
> >
> > lists@jimisola.com wrote:
> >
> >> I've made some additions/changes to get Commons HttpClient working
> >> correctly
> >> with Apache XML-RPC which I think can be helpful for others as well.
> >
> > Given the facts that the CommonsXmlRpcTransportTest works quite fine and
> > that a real lot of people are using the CommonsXmlRpcTransport (me not
> > included, to be honest), I wonder what your patches are good for? I think,
> > there's some explanation required.
> >
> >
> > Jochen
> >
>
> Well, there were two of us at work that tried to get it to work but we could
> not see how things were connected with the DefaultXmlRpcTransportFactory.
> Then I realized that I don't think that DefaultXmlRpcTransportFactory can be
> used to get instances of CommonsXmlRpcTransport. Or?
>
> Did not think to search for a test. However, I had a look at the
> CommonsXmlRpcTransportTest now and it does not seem to do much more than
> call the constructor...? When on tests, have this projects considered to use
> a code (test) coverage tool? My project uses Cobertura (cobertura.sf.net)
> and are _very_ pleased with what it has done for us.
>
> Anyway, as I mentioned initially that I forgot to use the CVS version of
> CommonsXmlRpcTransport and therefore I added method for setting (read)
> timeout and connection timeout (setTimeout and setConnectionTimeout).
> However, I saw that the exact same method with the same javadocs (from
> Commons HttpClient) had already been added, so my changes to
> CommonsXmlRpcTransport probably does not have any value (or diffs other than
> moving instance variables together).
>
> It might be that the CommonsHttpClientXmlRpcTransportFactory is unnecessary
> as well, but I did not get DefaultXmlRpcTransportFactory to do the job. Can
> it be used? Specifically, I want a factory class for CommonsXmlRpcTransport
> that I can set default timeout values on the factory object so that
> CommonsXmlRpcTransport classes are created with these timeout values.
>
> I don't like to take up your time like this. Think a lot of these
> misunderstandings/uncertainties could have been eliminated if the
> contribution documentation was more informative and information that is
> out-of-date (CVS, Bugzilla, ...) was removed from home page.
>
> That said, this project is something that I have much use for and I might be
> able to give it some time since I am not currently working with any
> open-source project and would like to do so.
>
> Kind regards,
> Jimisola
>
>
Re: [PATCH]Patches and additions to make HttpClient work with Apache XML-RPC
Posted by Jimisola Laursen <li...@jimisola.com>.
----- Original Message -----
From: "Jochen Wiedmann" <jo...@gmail.com>
To: <xm...@ws.apache.org>
Sent: Friday, October 21, 2005 9:35 PM
Subject: Re: [PATCH]Patches and additions to make HttpClient work with
Apache XML-RPC
>
> lists@jimisola.com wrote:
>
>> I've made some additions/changes to get Commons HttpClient working
>> correctly
>> with Apache XML-RPC which I think can be helpful for others as well.
>
> Given the facts that the CommonsXmlRpcTransportTest works quite fine and
> that a real lot of people are using the CommonsXmlRpcTransport (me not
> included, to be honest), I wonder what your patches are good for? I think,
> there's some explanation required.
>
>
> Jochen
>
Well, there were two of us at work that tried to get it to work but we could
not see how things were connected with the DefaultXmlRpcTransportFactory.
Then I realized that I don't think that DefaultXmlRpcTransportFactory can be
used to get instances of CommonsXmlRpcTransport. Or?
Did not think to search for a test. However, I had a look at the
CommonsXmlRpcTransportTest now and it does not seem to do much more than
call the constructor...? When on tests, have this projects considered to use
a code (test) coverage tool? My project uses Cobertura (cobertura.sf.net)
and are _very_ pleased with what it has done for us.
Anyway, as I mentioned initially that I forgot to use the CVS version of
CommonsXmlRpcTransport and therefore I added method for setting (read)
timeout and connection timeout (setTimeout and setConnectionTimeout).
However, I saw that the exact same method with the same javadocs (from
Commons HttpClient) had already been added, so my changes to
CommonsXmlRpcTransport probably does not have any value (or diffs other than
moving instance variables together).
It might be that the CommonsHttpClientXmlRpcTransportFactory is unnecessary
as well, but I did not get DefaultXmlRpcTransportFactory to do the job. Can
it be used? Specifically, I want a factory class for CommonsXmlRpcTransport
that I can set default timeout values on the factory object so that
CommonsXmlRpcTransport classes are created with these timeout values.
I don't like to take up your time like this. Think a lot of these
misunderstandings/uncertainties could have been eliminated if the
contribution documentation was more informative and information that is
out-of-date (CVS, Bugzilla, ...) was removed from home page.
That said, this project is something that I have much use for and I might be
able to give it some time since I am not currently working with any
open-source project and would like to do so.
Kind regards,
Jimisola
Re: [PATCH]Patches and additions to make HttpClient work with Apache
XML-RPC
Posted by Jochen Wiedmann <jo...@gmail.com>.
lists@jimisola.com wrote:
> I've made some additions/changes to get Commons HttpClient working correctly
> with Apache XML-RPC which I think can be helpful for others as well.
Given the facts that the CommonsXmlRpcTransportTest works quite fine and
that a real lot of people are using the CommonsXmlRpcTransport (me not
included, to be honest), I wonder what your patches are good for? I
think, there's some explanation required.
Jochen
Re: Road Map, Collections support etc
Posted by Jochen Wiedmann <jo...@gmail.com>.
Jimisola Laursen wrote:
> Looks promising. The streaming branch is using Maps (at least).
> May I ask how far gone it is this? Is there anyone else working on it
> (now)?
Noone else is currently working on it. However, from time to time
someone asks for a feature on this list (for example you) and its
becoming a standard reply from me to refer to the branch. So I hope that
someone will pick it up at any time.
Jochen
Re: Road Map, Collections support etc
Posted by Jimisola Laursen <li...@jimisola.com>.
----- Original Message -----
From: "Jochen Wiedmann" <jo...@gmail.com>
To: <xm...@ws.apache.org>
Sent: Thursday, October 20, 2005 9:59 PM
Subject: Re: Road Map, Collections support etc
> Jimisola Laursen wrote:
>
>> I know that it has been up before - Apache XML-RPC and Collections
>> classes support.
>> It should not take too long to do it. I'll even volunteer for it. What
>> reasons are there not to leave Vector/HashTable for List/Map?
>
> Please, take a look at the b20050512_streaming branch.
>
>
> Jochen
Looks promising. The streaming branch is using Maps (at least).
May I ask how far gone it is this? Is there anyone else working on it (now)?
Jimisola
Re: Road Map, Collections support etc
Posted by Jochen Wiedmann <jo...@gmail.com>.
Jimisola Laursen wrote:
> I know that it has been up before - Apache XML-RPC and Collections
> classes support.
> It should not take too long to do it. I'll even volunteer for it. What
> reasons are there not to leave Vector/HashTable for List/Map?
Please, take a look at the b20050512_streaming branch.
Jochen
Road Map, Collections support etc
Posted by Jimisola Laursen <li...@jimisola.com>.
Hi!
I was so glad when WS Apache XML-RPC got some activety back and 2.0 came out.
But, if one reads the project reports then activety seems to have slowed down
again.
Documentation definitely needs an update and I guess there have been some bug
fixes and patches to 2.0.
What are the plans? Is there a road map available?
I know that it has been up before - Apache XML-RPC and Collections classes
support.
It should not take too long to do it. I'll even volunteer for it. What reasons
are there not to leave Vector/HashTable for List/Map?
Regards,
Jimisola
Re: [PATCH]Patches and additions to make HttpClient work with Apache XML-RPC
Posted by li...@jimisola.com.
Forgot to add example code:
URL url = new URL("http://" + "localhost" + ':' + 5077 + "/RPC2");
CommonsHttpClientXmlRpcTransportFactory factory = new
CommonsHttpClientXmlRpcTransportFactory(url.getHost(), url.getPort());
factory.setConnectionTimeout(20000);
factory.setTimeout(4000);
XmlRpcClient xmlRpcClient = new XmlRpcClient(url, factory);
XmlRpc.setDebug(true);
Object result;
result = xmlRpcClient.execute("test", new Vector());
System.out.println(result);