Java SOAP client to access web service through authenicating proxy server

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(
                  "org.uddi4j.TransportClassName",
                  "org.uddi4j.transport.ApacheAxisTransport");
            
            
            System.setProperty("http.proxyHost", "xxx.xxxx.com"); // changed for security            //System.setProperty("http.proxyHost","localhost");
            //System.setProperty("http.proxyPort","9070");
            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 =
                        busList.getBusinessInfos().getBusinessInfoVector();
                  BusinessInfo busInfo = null;

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

            } catch (MalformedURLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            } catch (UDDIException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            } catch (TransportException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
// 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!
LVL 2
rbrogan_eeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mayank SAssociate Director - Product EngineeringCommented:
>> System.setProperty("http.proxyUserName", "domaninx\\userxxx");

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

Thanks
Raja
rbrogan_eeAuthor Commented:
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)

Thanks
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

rajaamirapuCommented:
See this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4433701
There is workarround given for this issue
actonwangCommented:
You have https, so i am wondering if you have set up JSSE already.
rbrogan_eeAuthor Commented:
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?

Thanks,
Roger
rbrogan_eeAuthor Commented:
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?


Thanks,
Roger
actonwangCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mayank SAssociate Director - Product EngineeringCommented:
>> 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 SAssociate Director - Product EngineeringCommented:
So you used HttpClient?
rbrogan_eeAuthor Commented:
mayankeagle,

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.


actonwangCommented:
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.
rbrogan_eeAuthor Commented:
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?

Thanks,
Roger
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.