Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

WSIF client to invoke protected Web Services  RSS feed

 
RajeshG Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using WSIF 2.0 and trying to invoke a protected WS.

I am not able to find a way to add the credential in the request. Can you please guide/help me in that?

Thank you. I would really appreciate your co-operation.

Please let me know any other information is required.

I have tried adding header like this

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

WSIFMessage portCtx = defPort.getContext();
System.out.println("portCtx "+portCtx);
portCtx.setObjectPart(org.
apache.wsif.WSIFConstants.CONTEXT_HTTP_USER,"username");
portCtx.setObjectPart(org.apache.wsif.WSIFConstants.CONTEXT_HTTP_PSWD,"password");
defPort.setContext(portCtx);

or*************************************************************************

WSIFOperation wsoperation = defPort.createOperation(wsoperationName, wsinputName, wsoutputName);
WSIFMessage input = wsoperation.createInputMessage();

WSIFMessage context = wsoperation.getContext();

context.setObjectPart(org.apache.wsif.WSIFConstants.CONTEXT_HTTP_USER,"username");
context.setObjectPart(org.apache.wsif.WSIFConstants.CONTEXT_HTTP_PSWD,"password");
wsoperation.setContext(context);

also used like this*******************************************************************
Hashtable httpHeaders = new Hashtable();
//Add header info (Header Name/Value pair)
httpHeaders.put("Username", "xxxxxxxxx");
httpHeaders.put("Password", "xxxxxxxxxxxx");

context.setObjectPart(org.apache.wsif.WSIFConstants.CONTEXT_REQUEST_SOAP_HEADERS,httpHeaders);
wsoperation.setContext(context);

I am getting the following exception.

defPort org.apache.wsif.providers.soap.apacheaxis.WSIFPort_ApacheAxis@faa550
portCtx org.apache.wsif.base.WSIFDefaultMessage@17b6643 name:null parts:null
context org.apache.wsif.base.WSIFDefaultMessage@da2cef name:null
Executing operation insert
org.apache.wsif.WSIFException: exception on AXIS invoke: (401)Authorization Required; nested exception is:
(401)Authorization Required
at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeAXISDocStyle(Unknown Source)
at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeRequestResponseOperation(Unknown Source)
at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.executeRequestResponseOperation(Unknown Source)
at com.ws.client.WsifWSClient.main(WsifWSClient.java:254)
Caused by: (401)Authorization Required
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:630)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:131)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:182)
at org.apache.axis.client.Call.invokeEngine(Call.java:2113)
at org.apache.axis.client.Call.invoke(Call.java:2102)
at org.apache.axis.client.Call.invoke(Call.java:1851)
at org.apache.axis.client.Call.invoke(Call.java:1777)
at org.apache.axis.client.Call.invoke(Call.java:1315)
... 4 more
BUILD SUCCESSFUL (total time: 8 seconds)

Thank you

Rajesh Kumar
 
Pat Gonzalez
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an example, http://spnego.sourceforge.net/protected_soap_service.html, that uses windows integrated authentication/sso.

Perhaps something in the example might help...?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!