• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing Authentication Parameters while consuming a web service  RSS feed

Shruti Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am facing a problem:

There is a web service that I need to consume. When I write a standolone test client and run it through the 'main' method it runs well. But when I try to run through my web application the authentication fails.

Here is the code snippet that I am trying:


String urlString = "";
//String urlString = "http://localhost:9082/VaCMSSPIDeRDrillDown/VaCmsSpiderServiceImplService/WEB-INF/wsdl/SPDR.wsdl";

String nameSpace = "http://www.deloitte.com/VaCMS";
String serviceName = "VaCmsSpiderServiceImplService";
QName qName = new QName(nameSpace, serviceName);

URL url = new URL(urlString);
VaCmsSpiderServiceImplPortProxy serviceProxy = new VaCmsSpiderServiceImplPortProxy(url, qName);

Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("CMS_SPIDER_DD"));
headers.put("Password", Collections.singletonList("CMS_SPIDER_DD"));

((BindingProvider)serviceProxy._getDescriptor().getProxy()).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);

VaCmsCaseInfoByClientId request2 = new VaCmsCaseInfoByClientId();
VaCmsCaseInfoByClientIdRequest clientId = new VaCmsCaseInfoByClientIdRequest();

VaCmsCaseInfoResponse response2 = serviceProxy.getVaCmsCaseInfoByClientId(request2);

}catch(Exception e){


Please note the way I am passing the authentication parameters. The same code works when run as main method but the authentication is failing if I run through the web application.

Please assist. It is somewhat urgent.

Thank you,
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!