You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Paul Wilton <Pa...@bbc.com> on 2009/08/27 12:26:00 UTC

using jax-rs WebClient through proxy server

Hi

I am using org.apache.cxf.jaxrs.client.WebClient to access a REST
service that sits behind a squid proxy server. The rest client WebClient
is running on Tomcat.
 
I have set JAVA_OPTS in the catalina startup script with my proxy server
settings:
-Dhttp.proxyHost=my.proxy.domain
-Dhttp.proxyPort=80
-Dhttp.nonProxyHosts=localhost,127.0.0.1
 
But the requests do not make it past the proxy server, and I just get
socket connection timeouts
 
Just to clarify, 
My WebClient works fine when not behind a proxy server, and I can also
access the restful service using curl -x on the command line giving the
same proxy details.
 
My questions:
Does WebClient handle proxy servers ok ?
Is passing the proxy details to the JVM using java opts a valid
technique with WebClient ?
Is there some specific way of configuring WebClient to use proxy servers
?
 
Thanks for any help
Paul 
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
 
Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this

This e-mail has been sent by one of the following wholly-owned subsidiaries of the BBC:
 
BBC Worldwide Limited, Registration Number: 1420028 England, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ

Re: using jax-rs WebClient through proxy server

Posted by Sergey Beryozkin <se...@iona.com>.
The location of the configuration files has changed (as a result of the
Benson's effort), here're the updated links :

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https.xml

and

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-url.xml

cheers, Sergey


Sergey Beryozkin wrote:
> 
> Hi Paul
> 
> After talking to Dan I've realized that you can already limit an
> http-conduit configuration to individual URIs.
> 
> For example, if the endpoint address starts with
> "http://books:9095/bookstore" then one can do :
> 
> <http:conduit name="http://books:9095/bookstore.*"/>
> 
> This way you can have conduits for production and test URIs (as proposed
> by Dan).
> 
> Additionally, one can also have http conduits identified similarly to the
> way they're identified for SOAP-based clients.
> 
> For WebClients you can do :
> 
> <http:conduit name="{http://books:9095/bookstore}WebClient.http-conduit"/>
> (in 2.2.3 the local name is 'WebResource', I updated it to 'WebClient' )
> 
> 
> For proxies you can do :
> 
> <http:conduit
> name="{http://jaxrs.systest.cxf.apache.org/}BookStore.http-conduit"/>
> 
> (in 2.2.3 additional 'jaxrs' suffix is added tp the namespace, I remoced
> it on the trunk )
> 
> where 'jaxrs.systest.cxf.apache.org' is a reverse package name
> 
> I'm also thinking of letting users to directly inject an HTTPConfigPolicy
> instances during the creation time for simple cases. Also, I added
> ClientConfiguration.getHttpConduit() to avoid casts - for JAXRS it will be
> HTTP in most cases..
> 
> Please see updated
> 
> http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https.xml
> 
> and
> 
> http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-url.xml
> 
> thanks, Sergey
> 
> 
> 
> Paul Wilton wrote:
>> 
>> Hi
>> 
>> I am using org.apache.cxf.jaxrs.client.WebClient to access a REST
>> service that sits behind a squid proxy server. The rest client WebClient
>> is running on Tomcat.
>>  
>> I have set JAVA_OPTS in the catalina startup script with my proxy server
>> settings:
>> -Dhttp.proxyHost=my.proxy.domain
>> -Dhttp.proxyPort=80
>> -Dhttp.nonProxyHosts=localhost,127.0.0.1
>>  
>> But the requests do not make it past the proxy server, and I just get
>> socket connection timeouts
>>  
>> Just to clarify, 
>> My WebClient works fine when not behind a proxy server, and I can also
>> access the restful service using curl -x on the command line giving the
>> same proxy details.
>>  
>> My questions:
>> Does WebClient handle proxy servers ok ?
>> Is passing the proxy details to the JVM using java opts a valid
>> technique with WebClient ?
>> Is there some specific way of configuring WebClient to use proxy servers
>> ?
>>  
>> Thanks for any help
>> Paul 
>> This e-mail (and any attachments) is confidential and may contain
>> personal views which are not the views of the BBC unless specifically
>> stated. If you have received it in error, please delete it from your
>> system. Do not use, copy or disclose the information in any way nor act
>> in reliance on it and notify the sender immediately.
>>  
>> Please note that the BBC monitors e-mails sent or received. Further
>> communication will signify your consent to this
>> 
>> This e-mail has been sent by one of the following wholly-owned
>> subsidiaries of the BBC:
>>  
>> BBC Worldwide Limited, Registration Number: 1420028 England, Registered
>> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
>> BBC World News Limited, Registration Number: 04514407 England, Registered
>> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
>> BBC World Distribution Limited, Registration Number: 04514408, Registered
>> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/using-jax-rs-WebClient-through-proxy-server-tp25169942p25237457.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: using jax-rs WebClient through proxy server

Posted by Sergey Beryozkin <se...@iona.com>.
Hi Paul

After talking to Dan I've realized that you can already limit an
http-conduit configuration to individual URIs.

For example, if the endpoint address starts with
"http://books:9095/bookstore" then one can do :

<http:conduit name="http://books:9095/bookstore.*"/>

This way you can have conduits for production and test URIs (as proposed by
Dan).

Additionally, one can also have http conduits identified similarly to the
way they're identified for SOAP-based clients.

For WebClients you can do :

<http:conduit name="{http://books:9095/bookstore}WebClient.http-conduit"/>
(in 2.2.3 the local name is 'WebResource', I updated it to 'WebClient' )


For proxies you can do :

<http:conduit
name="{http://jaxrs.systest.cxf.apache.org/}BookStore.http-conduit"/>

(in 2.2.3 additional 'jaxrs' suffix is added tp the namespace, I remoced it
on the trunk )

where 'jaxrs.systest.cxf.apache.org' is a reverse package name

I'm also thinking of letting users to directly inject an HTTPConfigPolicy
instances during the creation time for simple cases. Also, I added
ClientConfiguration.getHttpConduit() to avoid casts - for JAXRS it will be
HTTP in most cases..

Please see updated

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https.xml

and

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-url.xml

thanks, Sergey



Paul Wilton wrote:
> 
> Hi
> 
> I am using org.apache.cxf.jaxrs.client.WebClient to access a REST
> service that sits behind a squid proxy server. The rest client WebClient
> is running on Tomcat.
>  
> I have set JAVA_OPTS in the catalina startup script with my proxy server
> settings:
> -Dhttp.proxyHost=my.proxy.domain
> -Dhttp.proxyPort=80
> -Dhttp.nonProxyHosts=localhost,127.0.0.1
>  
> But the requests do not make it past the proxy server, and I just get
> socket connection timeouts
>  
> Just to clarify, 
> My WebClient works fine when not behind a proxy server, and I can also
> access the restful service using curl -x on the command line giving the
> same proxy details.
>  
> My questions:
> Does WebClient handle proxy servers ok ?
> Is passing the proxy details to the JVM using java opts a valid
> technique with WebClient ?
> Is there some specific way of configuring WebClient to use proxy servers
> ?
>  
> Thanks for any help
> Paul 
> This e-mail (and any attachments) is confidential and may contain personal
> views which are not the views of the BBC unless specifically stated. If
> you have received it in error, please delete it from your system. Do not
> use, copy or disclose the information in any way nor act in reliance on it
> and notify the sender immediately.
>  
> Please note that the BBC monitors e-mails sent or received. Further
> communication will signify your consent to this
> 
> This e-mail has been sent by one of the following wholly-owned
> subsidiaries of the BBC:
>  
> BBC Worldwide Limited, Registration Number: 1420028 England, Registered
> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
> BBC World News Limited, Registration Number: 04514407 England, Registered
> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
> BBC World Distribution Limited, Registration Number: 04514408, Registered
> Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
> 
> 

-- 
View this message in context: http://www.nabble.com/using-jax-rs-WebClient-through-proxy-server-tp25169942p25192647.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: using jax-rs WebClient through proxy server

Posted by Paul Wilton <Pa...@bbc.com>.
Hi Sergey
Yes, that works okay, setting a proxy server on *.http-conduit
It would be really nice to be able to set this up on a per WebClient
endpoint/conduit basis though

Thanks  :)
Paul


-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com] 
Sent: 27 August 2009 12:29
To: Paul Wilton; users@cxf.apache.org
Cc: sergey.beryozkin@iona.com
Subject: Re: using jax-rs WebClient through proxy server

Hi Paul

Sorry for a delay, I was actually about to advise you to use the in-code
configuration :-).
Will it work if you do the (proxy-related) conduit configuration similar
to the way it's done here :
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apa
che/cxf/systest/jaxrs/security/jaxrs-https.xml
?
I've found the similar question here :

http://www.nabble.com/Configuring-http-proxy-port-for-http-conduit-in-Sp
ring-application-context-td20399620.html

So you can probably do

<http:conduit name="*.http-conduit">
<http:client  ProxyServer="my.proxy.domain" ProxyServerPort="80"/>
</http:conduit>

This will apply to all the clients though - so I'm not sure yet how to
identify an http:conduit instance with a single client only - 
I may need to fix something there. I'll look into it, hopefully you can
make it workingby using the above configuration as well...- 
let me know please if it will work

cheers, Sergey

----- Original Message ----- 
From: "Paul Wilton" <Pa...@bbc.com>
To: <us...@cxf.apache.org>
Cc: <se...@iona.com>
Sent: Thursday, August 27, 2009 12:11 PM
Subject: RE: using jax-rs WebClient through proxy server


Hi Sergey
Regading my original question below, I have now successfully set proxy
server details programmatically by getting hold of the HTTPConduit of
the WebClient at runtime as follows:

        HTTPConduit conduit =
(HTTPConduit)WebClient.getConfig(webClient).getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        policy.setProxyServer("my.proxy.domain");
        policy.setProxyServerPort(80);

However, this is not ideal - I really want to set conduit in my Spring
config
I can see in the docs how to associate a spring configured HTTPSConduit
with a JAX-WS client,

But how do I associate a HTTPConduit with a JAX-RS client in spring?

Where my WebClient is configured as a bean in spring as follows:
    <bean id="myWebClient" class="org.apache.cxf.jaxrs.client.WebClient"
factory-method="create">
        <constructor-arg type="java.lang.String"
value="${my.restful.service.url}" />
        <constructor-arg ref="myWebClientProviders" />
    </bean>

I don't see any obvious way of associating a HTTPConduit with the
endpoint

Thanks
Paul




-----Original Message-----
From: Paul Wilton [mailto:Paul.Wilton@bbc.com]
Sent: 27 August 2009 11:26
To: users@cxf.apache.org
Subject: using jax-rs WebClient through proxy server

Hi

I am using org.apache.cxf.jaxrs.client.WebClient to access a REST
service that sits behind a squid proxy server. The rest client WebClient
is running on Tomcat.

I have set JAVA_OPTS in the catalina startup script with my proxy server
settings:
-Dhttp.proxyHost=my.proxy.domain
-Dhttp.proxyPort=80
-Dhttp.nonProxyHosts=localhost,127.0.0.1

But the requests do not make it past the proxy server, and I just get
socket connection timeouts

Just to clarify,
My WebClient works fine when not behind a proxy server, and I can also
access the restful service using curl -x on the command line giving the
same proxy details.

My questions:
Does WebClient handle proxy servers ok ?
Is passing the proxy details to the JVM using java opts a valid
technique with WebClient ?
Is there some specific way of configuring WebClient to use proxy servers
?

Thanks for any help
Paul
This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated. If you have received it in error, please delete it from your
system. Do not use, copy or disclose the information in any way nor act
in reliance on it and notify the sender immediately.

Please note that the BBC monitors e-mails sent or received. Further
communication will signify your consent to this

This e-mail has been sent by one of the following wholly-owned
subsidiaries of the BBC:

BBC Worldwide Limited, Registration Number: 1420028 England, Registered
Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ 


Re: using jax-rs WebClient through proxy server

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Paul

Sorry for a delay, I was actually about to advise you to use the in-code configuration :-).
Will it work if you do the (proxy-related) conduit configuration similar to the way it's done here :
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https.xml
?
I've found the similar question here :

http://www.nabble.com/Configuring-http-proxy-port-for-http-conduit-in-Spring-application-context-td20399620.html

So you can probably do

<http:conduit name="*.http-conduit">
<http:client  ProxyServer="my.proxy.domain" ProxyServerPort="80"/>
</http:conduit>

This will apply to all the clients though - so I'm not sure yet how to identify an http:conduit instance with a single client only - 
I may need to fix something there. I'll look into it, hopefully you can make it workingby using the above configuration as well...- 
let me know please if it will work

cheers, Sergey

----- Original Message ----- 
From: "Paul Wilton" <Pa...@bbc.com>
To: <us...@cxf.apache.org>
Cc: <se...@iona.com>
Sent: Thursday, August 27, 2009 12:11 PM
Subject: RE: using jax-rs WebClient through proxy server


Hi Sergey
Regading my original question below, I have now successfully set proxy
server details programmatically by getting hold of the HTTPConduit of
the WebClient at runtime as follows:

        HTTPConduit conduit =
(HTTPConduit)WebClient.getConfig(webClient).getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        policy.setProxyServer("my.proxy.domain");
        policy.setProxyServerPort(80);

However, this is not ideal - I really want to set conduit in my Spring
config
I can see in the docs how to associate a spring configured HTTPSConduit
with a JAX-WS client,

But how do I associate a HTTPConduit with a JAX-RS client in spring?

Where my WebClient is configured as a bean in spring as follows:
    <bean id="myWebClient" class="org.apache.cxf.jaxrs.client.WebClient"
factory-method="create">
        <constructor-arg type="java.lang.String"
value="${my.restful.service.url}" />
        <constructor-arg ref="myWebClientProviders" />
    </bean>

I don't see any obvious way of associating a HTTPConduit with the
endpoint

Thanks
Paul




-----Original Message-----
From: Paul Wilton [mailto:Paul.Wilton@bbc.com]
Sent: 27 August 2009 11:26
To: users@cxf.apache.org
Subject: using jax-rs WebClient through proxy server

Hi

I am using org.apache.cxf.jaxrs.client.WebClient to access a REST
service that sits behind a squid proxy server. The rest client WebClient
is running on Tomcat.

I have set JAVA_OPTS in the catalina startup script with my proxy server
settings:
-Dhttp.proxyHost=my.proxy.domain
-Dhttp.proxyPort=80
-Dhttp.nonProxyHosts=localhost,127.0.0.1

But the requests do not make it past the proxy server, and I just get
socket connection timeouts

Just to clarify,
My WebClient works fine when not behind a proxy server, and I can also
access the restful service using curl -x on the command line giving the
same proxy details.

My questions:
Does WebClient handle proxy servers ok ?
Is passing the proxy details to the JVM using java opts a valid
technique with WebClient ?
Is there some specific way of configuring WebClient to use proxy servers
?

Thanks for any help
Paul
This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated. If you have received it in error, please delete it from your
system. Do not use, copy or disclose the information in any way nor act
in reliance on it and notify the sender immediately.

Please note that the BBC monitors e-mails sent or received. Further
communication will signify your consent to this

This e-mail has been sent by one of the following wholly-owned
subsidiaries of the BBC:

BBC Worldwide Limited, Registration Number: 1420028 England, Registered
Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ 


RE: using jax-rs WebClient through proxy server

Posted by Paul Wilton <Pa...@bbc.com>.
Hi Sergey
Regading my original question below, I have now successfully set proxy
server details programmatically by getting hold of the HTTPConduit of
the WebClient at runtime as follows:

        HTTPConduit conduit =
(HTTPConduit)WebClient.getConfig(webClient).getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        policy.setProxyServer("my.proxy.domain");
        policy.setProxyServerPort(80);

However, this is not ideal - I really want to set conduit in my Spring
config 
I can see in the docs how to associate a spring configured HTTPSConduit
with a JAX-WS client,

But how do I associate a HTTPConduit with a JAX-RS client in spring?

Where my WebClient is configured as a bean in spring as follows:
    <bean id="myWebClient" class="org.apache.cxf.jaxrs.client.WebClient"
factory-method="create">
        <constructor-arg type="java.lang.String"
value="${my.restful.service.url}" />
        <constructor-arg ref="myWebClientProviders" />
    </bean>

I don't see any obvious way of associating a HTTPConduit with the
endpoint

Thanks
Paul




-----Original Message-----
From: Paul Wilton [mailto:Paul.Wilton@bbc.com] 
Sent: 27 August 2009 11:26
To: users@cxf.apache.org
Subject: using jax-rs WebClient through proxy server

Hi

I am using org.apache.cxf.jaxrs.client.WebClient to access a REST
service that sits behind a squid proxy server. The rest client WebClient
is running on Tomcat.
 
I have set JAVA_OPTS in the catalina startup script with my proxy server
settings:
-Dhttp.proxyHost=my.proxy.domain
-Dhttp.proxyPort=80
-Dhttp.nonProxyHosts=localhost,127.0.0.1
 
But the requests do not make it past the proxy server, and I just get
socket connection timeouts
 
Just to clarify, 
My WebClient works fine when not behind a proxy server, and I can also
access the restful service using curl -x on the command line giving the
same proxy details.
 
My questions:
Does WebClient handle proxy servers ok ?
Is passing the proxy details to the JVM using java opts a valid
technique with WebClient ?
Is there some specific way of configuring WebClient to use proxy servers
?
 
Thanks for any help
Paul 
This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated. If you have received it in error, please delete it from your
system. Do not use, copy or disclose the information in any way nor act
in reliance on it and notify the sender immediately.
 
Please note that the BBC monitors e-mails sent or received. Further
communication will signify your consent to this

This e-mail has been sent by one of the following wholly-owned
subsidiaries of the BBC:
 
BBC Worldwide Limited, Registration Number: 1420028 England, Registered
Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408,
Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ