I have (at work) a proxy which requires basic authentication. I am trying to
use the XFire dynamic client with an external web service that basically
looks like this.
Client client = new Client(new URL("
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"));
client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_USER,
"me");
client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PASS,
"secret");
client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST,
"host");
client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT,
"8080");
Object[] params = new Object[] {"USD", "EUR"};
Object[] rate = client.invoke("ConversionRate", params);
Before setting the authentication I read carefully the following page :-)
http://docs.codehaus.org/display/XFIRE/HTTP+Transport
The first problem I got is due to the fact that the client creation opens
a stream to the URL via the jdk URLConnection which does not support proxy
authentication. In order to bypass that problem I wrote my own
URLStreamHandler that uses org.apache.commons.httpclient.HttpClient (which
supports proxy authentication).
Using that I was able to create my client :-)
Then I faced a 407 error code stating that my proxy requires authentication
- Argh !
at org.codehaus.xfire.client.Client.invoke(Client.java:335)
at org.codehaus.xfire.client.Client.invoke(Client.java:349)
at CurrencyDynamicClient.main(CurrencyDynamicClient.java:47)
Caused by: org.codehaus.xfire.XFireRuntimeException: Server returned error
code = 407 for URI : http://www.webservicex.net/CurrencyConvertor.asmx.
Check server logs for details
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(
HttpChannel.java:133)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java
:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(
OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(
HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
... 3 more
I looked at
CommonsHttpMessageSender.java<file:///C:/workspace/testXFire/src/main/org/codehaus/xfire/transport/http/CommonsHttpMessageSender.java>and
the authentication seems correct to me the host/port/username/password
are correctly set (I did actually the same in my URLStreamHandler with
success). Nevertheless, the sender.send() in HTTPChannel gives me a 407
return code.
The only difference I see so far is that I hae a post instead of a get.
Does somebody else solve the same problem or has an idea of what I missed ?
Cheers
Guillaume