This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Authentication Parameters while consuming a web service

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

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:

****************************************************

try{
String urlString = "http://10.192.79.22:9081/VaCMSSPIDeRDrillDown/VaCmsSpiderServiceImplService/WEB-INF/wsdl/SPDR.wsdl";
//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();
clientId.setClientId(2100035757L);
request2.setArg0(clientId);

VaCmsCaseInfoResponse response2 = serviceProxy.getVaCmsCaseInfoByClientId(request2);
System.out.println(response2.getReturnCode());
System.out.println(response2.getReturnMessage());

}catch(Exception e){
e.printStackTrace();
}

************************************************************************

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,
-Shruti
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic