• Post Reply Bookmark Topic Watch Topic
  • New Topic

Invoking a web service behind a proxy server

 
ravindran shanmugam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting an Exception while trying to access Web services behind a proxy server setup. I am using JWSDP(Java Web Services DevelopmentPack)for the development.
I am using the following fragment of code in my client program.

//Setting the proxy properties
Properties myprops = new Properties();
myprops.setProperty("http.proxySet","true");
myprops.setProperty("http.proxyHost","hostname");
myprops.setProperty("http.proxyPort","port");
//encoding the authentication information
String userid = new sun.misc.BASE64Encoder().encode("user".getBytes());
String password = new sun.misc.BASE64Encoder().encode("password".getBytes());
myprops.setProperty("http.proxyUserName",userid);
myprops.setProperty("http.proxyPassword",password);
//Setting the system properties
Properties props = System.getProperties();
Enumeration iter = myprops.propertyNames();
while (iter.hasMoreElements()) {
String s = (String) iter.nextElement();
props.put(s, myprops.getProperty(s));

//Rest of the codes are for constructing the soap connection and message object.
I am getting proxy authentication error, listed below
javax.xml.soap.SOAPException: Bad response: (407Proxy Authentication Required ( The ISA Server requi
res authorization to fulfill the request. Access to the Web Proxy service is denied. )
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:267)

When we checked in our office proxy the request is coming from an anonymous user instead of the mentioned user id and password.
We are getting the same problem when we are suing the Apache AXIS tool kit.

In Apache SOAP tool kit there is an option for setting the proxy user id and password by using SOAPHTTPConnection. But we need to
use either JWSDP or Apache AXIS.
Solution to this problem would be highly appreciated.
Regards,
Saji
 
webaesthet
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrong:
myprops.setProperty("http.proxyUserName",userid);
Right:
myprops.setProperty("http.proxyUser",userid);
407 is the proxy authentication error. Proxy is not getting the user name due to the above error. I do think proxyUserName is more appropriate, but like many other things proxyUser - a misnomer is used and people are too lazy to change it.
regards,
Selva.
 
Ashok Kumar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm also getting the same error..

Here is the code that i'm using.

Properties proxyProps = new Properties();
proxyProps.setProperty("http.proxySet","true");
proxyProps.setProperty("http.proxyHost","proxy2.wipro.com");
proxyProps.setProperty("http.proxyPort","8080");
String user = userProperties.getProperty("user");
String pwd = userProperties.getProperty("pass");
String userid = new sun.misc.BASE64Encoder().encode(user.getBytes());
String password = new sun.misc.BASE64Encoder().encode(pwd.getBytes());
proxyProps.setProperty("http:proxyUser", userid);
proxyProps.setProperty("http:proxyPassword", password);
Properties systemProperties = System.getProperties();
Enumeration iterator = proxyProps.propertyNames();
while (iterator.hasMoreElements())
{
String s = (String) iterator.nextElement();
systemProperties.put(s, proxyProps.get(s));
}
}

Any idea on what might causing the problem?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!