This discussion is archived
1 Reply Latest reply: Oct 8, 2012 4:09 PM by vladodias RSS

Invoking a web service via proxy

abollu Newbie
Currently Being Moderated
Hi,

I have requirement to invoke a web service protected by basic http authentication.

I have generated a jax-ws proxy, the proxy makes a local copy of the wsdl.
And I use the following code to invoke it:

lDAPUserAdminService = new LDAPUserAdminService();
LDAPUserAdminServiceSoap lDAPUserAdminServiceSoap = lDAPUserAdminService.getLDAPUserAdminServiceSoap();

BindingProvider bindingProvider = (BindingProvider) lDAPUserAdminServiceSoap;
Map<String,Object> rc = (Map<String,Object>)bindingProvider.getRequestContext();
rc.put(BindingProvider.USERNAME_PROPERTY, "lclient");
rc.put(BindingProvider.PASSWORD_PROPERTY, "xxxxx");

lDAPUserAdminServiceSoap.getUser()..

it works fine for the url that is used to generate the proxy.

But when I try to invoke the same service deployed on a different server using the following code:

lDAPUserAdminService = new LDAPUserAdminService(
new URL("http://10.23.48.132:7003/LDAPAdminServices/user/LDAPUserAdminService.jws?wsdl"),
new QName("http://www.openuri.org/", "LDAPUserAdminService")); *//gives 401 error*

LDAPUserAdminServiceSoap lDAPUserAdminServiceSoap = lDAPUserAdminService.getLDAPUserAdminServiceSoap();

BindingProvider bindingProvider = (BindingProvider) lDAPUserAdminServiceSoap;
Map<String,Object> rc = (Map<String,Object>)bindingProvider.getRequestContext();
rc.put(BindingProvider.USERNAME_PROPERTY, "lclient");
rc.put(BindingProvider.PASSWORD_PROPERTY, "xxxxx");

lDAPUserAdminServiceSoap.getUser()..

I get 401 unauthorized error when trying to create the proxy itself trying to access the wsdl.

Is there any way to pass credentials programatically so that the proxy can access the wsdl.

Really appreciate any help!!
Anil

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points