Get your CodeRanch badge!*
The moose likes Web Services and the fly likes How to Call a web service from behind a firewall/Proxy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to Call a web service from behind a firewall/Proxy" Watch "How to Call a web service from behind a firewall/Proxy" New topic
Author

How to Call a web service from behind a firewall/Proxy

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 206
Do I need a different code when I need to call a web service from behind a firewall/Proxy..... Usually in corporate offices we are behind the firewall/Proxy server.

Do I need to pass the proxy settings before calling the web service.

If yes, how do we do that? Any clues?
David Nicholls
Greenhorn

Joined: Oct 10, 2011
Posts: 6

Hi Yogesh,

the easiest way may be to start your java client using the -D options for the proxy server.

-Dhttps.proxyHost=
-Dhttps.proxyPort=
-Dhttp.proxyHost=
-Dhttp.proxyPort=
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 206
That is the case when we are using a desktop application.

In my case, My class is being executed as a thread along with a web-application.
The thread gets started as soon as the server of the web-application starts.

Now in this case, I don't know how can I give -D option. Can I?

David Nicholls
Greenhorn

Joined: Oct 10, 2011
Posts: 6

Hi again,

in this case start your servlet container using these flags.

What is your environment? Are you using eclipse? Using tomcat?

Anyway. You may just as well alter your code:
Just put the following static initializer block in your thread class (or any class that is loaded before calling the service).

static {
System.setProperty("https.proxyHost", "IPgoesHere");
System.setProperty("https.proxyPort", "PortGoesHere");
System.setProperty("http.proxyHost", "IPgoesHere");
System.setProperty("http.proxyPort", "PortGoesHere");
}

I recommend starting the JVM using the -D options. Then you don't have to change your code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Call a web service from behind a firewall/Proxy
 
Similar Threads
accessing a web service from behind a firewall using wsad
Performance / Security Question
Call Web service behind the proxy of LAN
Axis 1.4 Error plz help Connect Exception
Accessing web service and rmi from internal network of dmz