This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes proxy settings in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "proxy settings in servlet" Watch "proxy settings in servlet" New topic
Author

proxy settings in servlet

dhaval.shah
Greenhorn

Joined: Oct 15, 2008
Posts: 7
Hello,
I have created war file for the project and it has been deployed on another server. i want to access it using the proxy settings like proxy url,name,port number, username, password . which i have stored in the proxy.properties file.

Even i have written a servlet that wil load a properties file in memory on start up. can anyone help me to how to create a some class that wil use the proxy settings and call the webservices on server on which it has been deployed ???
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
See if this (Proxy authentication in Java) helps you in anyway.


My Blog
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Not clear enough. Do you want to write a webservice client, to access the webservices exposed by the application deployed on the server?
dhaval.shah
Greenhorn

Joined: Oct 15, 2008
Posts: 7
i have created a webservice client and i am calling the stub i have generated using the WSDL. But the webservices are located on some other server say internet. To access it i need to pass through the proxy authentications.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Have tried the suggestion, given by Vinod?
dhaval.shah
Greenhorn

Joined: Oct 15, 2008
Posts: 7
yes i tried. but i m getting following exception



*************************************************************

11:44:16,688 INFO [STDOUT] 2008-10-30 11:44:16,688 ERROR [HttpMethodDirector-authenticate-235]-Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials


org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials


11:44:16,719 INFO [STDOUT] 2008-10-30 11:44:16,719 ERROR [searchTrip_jsp-_jspService-658]-Transport error: 407 Error: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
org.apache.axis2.AxisFault: Transport error: 407 Error: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )




***************************************************************
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Well, its NTLM. I would suggest you to read up a bit. Below are the related links.

Java 6 Http Authentication
NTLM Support in HttpClient
HttpClient NTLM Authentication

I hope it would help. Cheers.
dhaval.shah
Greenhorn

Joined: Oct 15, 2008
Posts: 7
hey thanks Adeel .. its working now.

I used the following code. if it could help you.
stub is the stub i have generated using WSDL file.

----------------------------------------------------------------------


HttpTransportProperties.ProxyProperties HTTPProxyProperties = new HttpTransportProperties.ProxyProperties();
HTTPProxyProperties.setProxyName("PROXY_NAME");
HTTPProxyProperties.setProxyPort("PROXY_PORT");
HTTPProxyProperties.setUserName("USER_NAME");HTTPProxyProperties.setPassWord(("PASSWORD"));HTTPProxyProperties.setDomain(("DOMAIN"));




Options options = stub._getServiceClient().getOptions();options.setProperty(MessageContextConstants.HTTP_PROTOCOL_VERSION,HTTPConstants.HEADER_PROTOCOL_10);options.setProperty(HTTPConstants.PROXY,HTTPProxyProperties);

----------------------------------------------------------------------

But the problem over here is that i had to use this lines of code everytime i make a call to stub when i am loading the HTTPProxyProperties object in servlet and loading into memory while calling stub. its not taking the proxy settings.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"dhaval.p. shah" please check your private messages for an important administrative matter.
Thanks.


SCJP, SCWCD.
|Asking Good Questions|
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"dhaval.shah" please check your private messages for an important administrative matter again.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: proxy settings in servlet
 
Similar Threads
Caching Proxy Server Advice
plugin proxy settings
Working with Internet URL from Eclipse
Proxy Servlet/Web Browser monitor
how to detect proxy sever setup?