Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WS-Security :How to send a SOAP message back to client on authentication error

 
priya verma
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using ws-security to protect my web service. I have implemented a passwordCallbackClass at the server for the protected web service as shown below . Before going to MyWebService , controls goes to passwordCallbackClass. Here I check the username and password sent by the client. If the user is invalid I want to send a response back to client in the form of SOAP message. Can anyone please help me in this...

<service name="MyWebService" provider="java:MSG">
<requestFlow>
<handler type="javarg.apache.ws.axis.security.WSDoAllReceiver">
<parameter name="passwordCallbackClass" value="PWCallback"/>
<parameter name="action" value="UsernameToken"/>
</handler>
</requestFlow>

Any help will be greatly appreciated!!!

Thanks
Priya
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, the Callbackhandler.handle method throw an IOException for any authentication failure, which will then be reported as a SOAPFault back to the client. You can pass a string with more information as a part of the exception, but I don't think you have much control over the SOAPFault in general. What exactly are you trying to accomplish?
 
priya verma
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

Thanks for the reply!

In case of authentication failure, I dont want to send a soapfault to client. Instead, I want to send an XML response to the client.This XML will contain the error.

Web service CLient code:

try{

1. Vector response = (Vector) call.invoke(input);
2. SOAPBodyElement elem = (SOAPBodyElement) response.get(0);
} catch (AxisFault af) {

Here, intead of getting the authentication error as AxisFault , I need to get the response in SOAPBodyElement at line 2.
Is there any way I can do this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic