Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Java SOAP client to access web service through authenicating proxy server

Posted on 2006-03-30
14
Medium Priority
?
3,867 Views
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(
                  "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!
0
Comment
Question by:rbrogan_ee
  • 5
  • 4
  • 3
  • +1
14 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 16332657
>> System.setProperty("http.proxyUserName", "domaninx\\userxxx");

Try without the domain-name there.
0
 
LVL 5

Expert Comment

by:rajaamirapu
ID: 16332876
Can you post the error message and the stack trace

Thanks
Raja
0
 
LVL 2

Author Comment

by:rbrogan_ee
ID: 16333189
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:rajaamirapu
ID: 16333265
See this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4433701
There is workarround given for this issue
0
 
LVL 19

Expert Comment

by:actonwang
ID: 16333668
You have https, so i am wondering if you have set up JSSE already.
0
 
LVL 2

Author Comment

by:rbrogan_ee
ID: 16333816
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
 
LVL 19

Expert Comment

by:actonwang
ID: 16333850
0
 
LVL 2

Author Comment

by:rbrogan_ee
ID: 16334848
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
 
LVL 19

Accepted Solution

by:
actonwang earned 2000 total points
ID: 16334988
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 16339350
>> 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
 
LVL 30

Expert Comment

by:Mayank S
ID: 16341749
So you used HttpClient?
0
 
LVL 2

Author Comment

by:rbrogan_ee
ID: 16362649
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
 
LVL 19

Expert Comment

by:actonwang
ID: 16363092
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
 
LVL 2

Author Comment

by:rbrogan_ee
ID: 16370171
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

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month21 days, 3 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question