We help IT Professionals succeed at work.

Java SOAP client to access web service through authenicating proxy server

rbrogan_ee asked
Medium Priority
Last Modified: 2012-05-05
I am trying to call a web service through a corporate proxy server.  The proxy server is Microsoft and requires NTLM authenication.

The development environment is WSAD 5.1.2.

 I have tried the following code.

System.setProperty("proxySet", "true");
            System.setProperty("http.proxyHost", "xxx.xxxx.com"); // changed for security            //System.setProperty("http.proxyHost","localhost");
            System.setProperty("http.proxyUserName", "domaninx\\userxxx");// changed for security
            System.setProperty("hhttp.proxyPassword", "xxx");// changed for security
            //Authenticator.setDefault( new ProxyAuth("domaninx\\userxxx","xxx"));
            String businessName = "Google";
            try {
                  UDDIProxy proxy =
                        new UDDIProxy(
                              new URL("http://uddi.sap.com/uddi/api/inquiry/"),
                              new URL("https://uddi.sap.com/uddi/api/publish/"));

                  //AuthToken token = proxy.get_authToken("xxxx", "xxxx");

                  Vector names = new Vector();
                  names.add(new Name(businessName));
                  BusinessList busList =
                        proxy.find_business(names, null, null, null, null, null, 10);

                  Vector busInfoVector =
                  BusinessInfo busInfo = null;

                  for (int i = 0; i < busInfoVector.size(); i++) {
                        busInfo = (BusinessInfo) busInfoVector.get(i);

            } catch (MalformedURLException e) {
                  // TODO Auto-generated catch block
            } catch (UDDIException e) {
                  // TODO Auto-generated catch block
            } catch (TransportException e) {
                  // TODO Auto-generated catch block
// below is a private class
      private static final class ProxyAuth extends java.net.Authenticator {
            private PasswordAuthentication auth;
            private ProxyAuth(String user, String pass) {
                  auth = new java.net.PasswordAuthentication(user, pass.toCharArray());

            protected PasswordAuthentication getPasswordAuthentication(){
                  return auth;

The lines that are commented out have been tried and give the same results.

I have tried every combination of setting the system properties and using the default authenicator.

Everything I try gives an operation timeout error.

My theories:

1.  The java SOAP client can't do NTLM authenication?
2.  It is getting to the proxy but the handshake with the proxy is timing out?

Not sure what the problem is.  Any help appreciated!  Thanks!
Watch Question

Mayank SPrincipal Technologist

>> System.setProperty("http.proxyUserName", "domaninx\\userxxx");

Try without the domain-name there.
Can you post the error message and the stack trace



I have tried it with the domain and without it.  Same result:

java.net.SocketException: Operation timed out: connect:could be due to invalid address
      at org.uddi4j.UDDIElement.<init>(Unknown Source)
      at org.uddi4j.response.BusinessList.<init>(Unknown Source)
      at org.uddi4j.client.UDDIProxy.find_business(Unknown Source)
      at com.mycom.uddi.UDDITest.main(UDDITest.java:62)

See this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4433701
There is workarround given for this issue
You have https, so i am wondering if you have set up JSSE already.


I have not set up JSSE.  That may explain this error which I get when I use the SSl connection:

javax.net.ssl.SSLHandshakeException: unexpected message
      at org.uddi4j.UDDIElement.<init>(Unknown Source)
      at org.uddi4j.response.AuthToken.<init>(Unknown Source)
      at org.uddi4j.client.UDDIProxy.get_authToken(Unknown Source)
      at com.mycom.uddi.UDDITest.main(UDDITest.java:61)

Will setting up JSSE fix it?  Can you point me to a resource on how to do that?



So I believe I understand the problem.  Correct me if I am wrong, but I believe that Java cannot do NTLM authentication over http?  Does everyone concur?  Or is there anyone who know how to do it?

NTLM authentication is nothing to do with http or https connection in your case.
NTLM is only required by your proxy server. You can use a java client with NTLM capability as commons/httpclient

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mayank SPrincipal Technologist

>> connect:could be due to invalid address

Verify that your proxy's machine-name is correct: >> System.setProperty("http.proxyHost", "xxx.xxxx.com");

Can you try with an IP-address there? If you have an automatic configuration-script, just type the address of the script in the browser and it will show you the IP-address of the proxy to be used.
Mayank SPrincipal Technologist

So you used HttpClient?



No I am not using HttpClient I am using the wsad 5.1.2 version of jax-rpc.

I would not have posted a question here without checking such silly things as spelling errors.  I would know if it was not hitting the correct proxy server and if you read the comments you would know that too because http code 407 is a response from an authenticating proxy server.
The problem is in the lack of support for a NTLM authenticating proxy.

if you have ntlm proxy, you'd have to have a ntlm plugin or subsys in your client side.

httpclient i mentioned is a good one with ntlm ability.


I do have an NTLM proxy.  And currently I am investigating if WSAD 5.1.2 with JAX-RPC can do it?  If not, will Rational Application Developer 6.0 be able to authenticate against an NTLM proxy with JAX-RPC?  And if that does not work, then which implementation of JAX-RPC will do it?  I do not want to drop to the HttpClient approach as I will then have to handle all the SOAP stuff my self.

Is this so unreasonable?

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.