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?
 
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

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

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

Thanks
Raja
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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


0
 
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.
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.