XFire

Recognize the Java runtime system variable for HTTP proxies

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1-RC1
  • Fix Version/s: 1.2.4
  • Component/s: None
  • Labels:
    None
  • Environment:
    N/A
  • Number of attachments :
    0

Description

Currently it seems that the only way to specify a proxy for an XFire client is by doing it programatically when creating the client:

MySoap client = stub.getMySoap();
Client http = ((XFireProxy) Proxy.getInvocationHandler(client)).getClient();
http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "localhost");
http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "8080");

This means that if you want to be able to transparently set a proxy you'll have to code some logic to check whether a property is set everywhere you create a client. A much more convenient way would be if the generated code from XFire took into account the standard Java environment properties for setting a proxy (as documented here: http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html). This would provide much convenience and flexibility in how to set whether or not to use an HTTP proxy as explained here: http://www.rgagnon.com/javadetails/java-0085.html.

Activity

Hide
Antoine Brocard added a comment -

Looks like it is the same issue than http://jira.codehaus.org/browse/XFIRE-279 (that is marked as RESOLVED). I have the same issue with xfire-1.1.2.

Show
Antoine Brocard added a comment - Looks like it is the same issue than http://jira.codehaus.org/browse/XFIRE-279 (that is marked as RESOLVED). I have the same issue with xfire-1.1.2.
Hide
Tomasz Sztelak added a comment -

fixed in svn

Show
Tomasz Sztelak added a comment - fixed in svn
Hide
Dan Diephouse added a comment -

Dan,

the said XFire issue is actually still bogus as XFire ignores the
standard Java system property "http.nonProxyHosts" as per
http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html.

Description:
XFire recognises the system properties "http.proxyHost" and
"http.proxyPort" but ignores "http.nonProxyHosts". In certain network
conditions, this has the effect that internal servers cannot be
contacted unless the (computer-)global proxy settings are set to direct
connections. This current behaviour practically either disables external
communications (with enabled internal communication) or internal
communications (with enabled external communication).

XFire version: 1.2.2
Affected class: org.codehaus.xfire.transport.http.CommonsHttpMessageSender
Affected method: private synchronized void createClient()

The attached patch shows the differences between my local copy and the
official source of class
org.codehaus.xfire.transport.http.CommonsHttpMessageSender in version 1.2.2.
[Local restrictions stop me from "diff"ing against the live SVN repository]

Cheers,
Michel


  • Michel <dot> Drescher <at> uk <dot> fujitsu <dot> com
    Fujitsu Laboratories of Europe
    +44 20 8606 4834
    ----BEGIN PGP SIGNATURE----
    Version: GnuPG v1.4.3 (Darwin)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFNP79k0lMZTNKw4QRAo1BAJ4pnrU1ERmfcuIrMOYX7waFnzRc+gCfQLlY
t5rmrLmchoNuWJOda6QwL6w=
=LEWX
----END PGP SIGNATURE----

7,11d6
< import java.net.Proxy;
< import java.net.ProxySelector;
< import java.net.URI;
< import java.net.URISyntaxException;
< import java.util.List;
68d62
< public static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts";
201,205d194
< String uri = context.getOutMessage().getUri();
< if ( isNonProxyHost(uri, context ) ) { < // this host does not need a proxy < return; < }
227,250d215
<
< private boolean isNonProxyHost( String strURI, MessageContext context ) {
< // convert String based URI into a URI class based URI ...
< URI uri = null;
< try { < uri = new URI( strURI ); < }
< catch (URISyntaxException use) { < // this should actually not happen, but just in case. < return false; < }
< // ... get a system platform ProxySelector, and ...
< ProxySelector ps = ProxySelector.getDefault();
< // ... let this selector return a list of proxies.
< List<Proxy> proxies = ps.select( uri );
< // If that lists sole element is of type Proxy.NO_PROXY
< // then we need a direct connection, otherwise we need to connect
< // through a proxy.
< if ( proxies.size() == 1 &&
< proxies.get(0).equals(Proxy.NO_PROXY ) ) { < return true; < }
< return false;
< }

Show
Dan Diephouse added a comment - Dan, the said XFire issue is actually still bogus as XFire ignores the standard Java system property "http.nonProxyHosts" as per http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html. Description: XFire recognises the system properties "http.proxyHost" and "http.proxyPort" but ignores "http.nonProxyHosts". In certain network conditions, this has the effect that internal servers cannot be contacted unless the (computer-)global proxy settings are set to direct connections. This current behaviour practically either disables external communications (with enabled internal communication) or internal communications (with enabled external communication). XFire version: 1.2.2 Affected class: org.codehaus.xfire.transport.http.CommonsHttpMessageSender Affected method: private synchronized void createClient() The attached patch shows the differences between my local copy and the official source of class org.codehaus.xfire.transport.http.CommonsHttpMessageSender in version 1.2.2. [Local restrictions stop me from "diff"ing against the live SVN repository] Cheers, Michel
  • – Michel <dot> Drescher <at> uk <dot> fujitsu <dot> com Fujitsu Laboratories of Europe +44 20 8606 4834 ----BEGIN PGP SIGNATURE---- Version: GnuPG v1.4.3 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFNP79k0lMZTNKw4QRAo1BAJ4pnrU1ERmfcuIrMOYX7waFnzRc+gCfQLlY t5rmrLmchoNuWJOda6QwL6w= =LEWX ----END PGP SIGNATURE---- 7,11d6 < import java.net.Proxy; < import java.net.ProxySelector; < import java.net.URI; < import java.net.URISyntaxException; < import java.util.List; 68d62 < public static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts"; 201,205d194 < String uri = context.getOutMessage().getUri(); < if ( isNonProxyHost(uri, context ) ) { < // this host does not need a proxy < return; < } 227,250d215 < < private boolean isNonProxyHost( String strURI, MessageContext context ) { < // convert String based URI into a URI class based URI ... < URI uri = null; < try { < uri = new URI( strURI ); < } < catch (URISyntaxException use) { < // this should actually not happen, but just in case. < return false; < } < // ... get a system platform ProxySelector, and ... < ProxySelector ps = ProxySelector.getDefault(); < // ... let this selector return a list of proxies. < List<Proxy> proxies = ps.select( uri ); < // If that lists sole element is of type Proxy.NO_PROXY < // then we need a direct connection, otherwise we need to connect < // through a proxy. < if ( proxies.size() == 1 && < proxies.get(0).equals(Proxy.NO_PROXY ) ) { < return true; < } < return false; < }
Hide
Dan Diephouse added a comment -

Fixed the non proxy hosts thing in SVN. Thanks.

Show
Dan Diephouse added a comment - Fixed the non proxy hosts thing in SVN. Thanks.
Hide
Philippe Jacot added a comment -

I tried the 1.2.3 version of maven-core today (found it on http://repository.codehaus.org/), and this issue doesn't seem to be fixed.
Looking at the the code of org/codehaus/xfire/transport/http/CommonsHttpMessageSender.java I think the problem is on line 269, there should be a newline in front of "return false; }"

259 + private boolean isNonProxyHost( String strURI, MessageContext context )
260 + {
261 + // convert String based URI into a URI class based URI ...
262 + URI uri = null;
263 + try
264 + { 265 + uri = new URI(strURI); 266 + }
267 + catch (URISyntaxException use)
268 + { // this should actually not happen, but just 269 + // in case. return false; }
270 + // ... get a system platform ProxySelector, and ...
271 + ProxySelector ps = ProxySelector.getDefault();
272 + // ... let this selector return a list of proxies.
273 + List proxies = ps.select(uri);
274 + // If that lists sole element is of type Proxy.NO_PROXY
275 + // then we need a direct connection, otherwise we need to connect
276 + // through a proxy.
277 + if (proxies.size() == 1 && proxies.get(0).equals(Proxy.NO_PROXY))
278 + { 279 + return true; 280 + }
281 + }
282 + return false;
283 + }

Show
Philippe Jacot added a comment - I tried the 1.2.3 version of maven-core today (found it on http://repository.codehaus.org/), and this issue doesn't seem to be fixed. Looking at the the code of org/codehaus/xfire/transport/http/CommonsHttpMessageSender.java I think the problem is on line 269, there should be a newline in front of "return false; }" 259 + private boolean isNonProxyHost( String strURI, MessageContext context ) 260 + { 261 + // convert String based URI into a URI class based URI ... 262 + URI uri = null; 263 + try 264 + { 265 + uri = new URI(strURI); 266 + } 267 + catch (URISyntaxException use) 268 + { // this should actually not happen, but just 269 + // in case. return false; } 270 + // ... get a system platform ProxySelector, and ... 271 + ProxySelector ps = ProxySelector.getDefault(); 272 + // ... let this selector return a list of proxies. 273 + List proxies = ps.select(uri); 274 + // If that lists sole element is of type Proxy.NO_PROXY 275 + // then we need a direct connection, otherwise we need to connect 276 + // through a proxy. 277 + if (proxies.size() == 1 && proxies.get(0).equals(Proxy.NO_PROXY)) 278 + { 279 + return true; 280 + } 281 + } 282 + return false; 283 + }
Hide
Tomasz Sztelak added a comment -

Patch depends on java 1.5 so i 'm going to remove it. But any java 1.4 compilant patches are welcome.

Show
Tomasz Sztelak added a comment - Patch depends on java 1.5 so i 'm going to remove it. But any java 1.4 compilant patches are welcome.
Hide
Tomasz Sztelak added a comment -

Fixed in svn. No proxy host checking works only on java 5 :/

Show
Tomasz Sztelak added a comment - Fixed in svn. No proxy host checking works only on java 5 :/

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: