GroovyWS HTTP Proxy Configuration

May 28, 2009

Here’s the story of how I got Groovy 1.6.3 and GroovyWS 0.5.0 to call a SOAP service through an HTTP proxy.

As of 28-May-2009, the GroovyWS website said…

Using proxies

If you are using a proxy for accessing internet, you can use the following environment variables to get rid of it:

  • proxyHost
  • proxyPort
  • proxy.user
  • proxy.password

or directly use the following in your proxy.setproxypropertie([:])

I tried to make HTTP proxy configuration work by following their instructions.  Unfortunately, the following three ways didn’t work :-(   I used various property naming conventions I saw in the GroovyWS javadocs and other online examples.

//A
proxy.setProxyProperties( [ "proxyHost":"proxy.foo.org", proxyPort:"8080", "proxy.user":"myUsername", "proxy.password":"myPassword" ] )

//B
proxy.setProxyProperties( [ "http.proxyHost":"proxy.foo.org", "http.proxyPort":"8080", "http.proxy.user":"myUsername", "http.proxy.password":"myPassword" ] )

//C
proxy.setProxyProperties( [ proxyHost:"proxy.foo.org", proxyPort:"8080", "http.proxy.user":"myUsername", "proxy.password":"myPassword" ] )

However, these two ways did work :-)

//D
System.setProperty(“http.proxyHost”, “proxy.foo.org”)
System.setProperty(“http.proxyPort”, “8080″)
System.setProperty(“http.proxy.user”, “myUsername”)
System.setProperty(“http.proxy.password”, “myPassword”)

//E
System.setProperty(“proxyHost”, “proxy.foo.org”)
System.setProperty(“proxyPort”, “8080″)
System.setProperty(“proxy.user”, “myUsername”)
System.setProperty(“proxy.password”, “myPassword”)

My conclusion is that either I called setProxyProperties() incorrectly or that it doesn’t work.  Setting the system properties directly was the only way I got GroovyWS to work through an HTTP proxy.

Here is the final working script:

import groovyx.net.ws.WSClient

System.setProperty("proxyHost",      "proxy.foo.org")
System.setProperty("proxyPort",      "8080")
System.setProperty("proxy.user",     "myUsername")
System.setProperty("proxy.password", "myPassword")

WSClient proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader)
proxy.initialize()
def result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"

NOTE: I used the GroovyWS uber jar: groovyws-standalone-0.5.0.jar.  Because it was taking too long, I gave up on trying use the GroovyWS minimal jar and then figuring out which CXF dependencies were needed for a simple SOAP client.

Entry Filed under: dev tools, groovy, java, soap. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

Recent Comments

Sridhar on Create an Executable Jar with…
ultraklon on GWT Serialization 2
ubuntudonateme on Amazing Ubuntu 8.10
Dan Rowley on GWT Serialization 2
cow on GWT Serialization 2

Categories

Meta