• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Yogesh Gandhi
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
IBM DB2 Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
IBM DB2 Eclipse IDE VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic