users@jax-rpc.java.net

How is a SOAPFAULT recieved on the client side ?????

From: Purbhoo, Hansika <PurbhooH_at_scmb.co.za>
Date: Wed, 24 Dec 2003 10:20:03 +0200

Hi All
I am using a handler to intercept my soap message.
In the handleRequest method, I extract out the username + password.
These are then validated against an existing legacy system.
Suppose the password is incorrect, I then set a SOAP fault on the message .

On the client side, I would expect the client to recieve a SOAP message
containg the SOAP fault, however the client is getting a SOAPFault exception

On my test client , I get the following exception

    javax.xml.rpc.soap.SOAPFaultException: Invalid password
    at
com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java:395)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSenderjava:234)

Why does the client get an exception instead of a normal SOAP Message ?
Is this the expected behaviour , or am I doing something incorrectly?

Here is the code in my handler
 public boolean handleRequest(MessageContext msgContext) {
    
     try {
       //try to authenticate user here, if there is an error an exception is
thrown
     } catch (SOAPFaultException sfe) {
       try {
         SOAPMessageContext smc = (SOAPMessageContext) msgContext;
         MessageFactory messageFactory = MessageFactory.newInstance();
         SOAPFactory soapFactory = SOAPFactory.newInstance();
         SOAPMessage message = messageFactory.createMessage();
         SOAPBody body = message.getSOAPBody();
         SOAPFault fault = body.addFault();
         Name faultName = soapFactory.createName("Client", "",
SOAPConstants.URI_NS_SOAP_ENVELOPE);
         fault.setFaultCode(faultName);
         fault.setFaultString("Invalid password");
         message.saveChanges();
         System.out.println("Here is what the XML message looks like:");
         message.writeTo(System.out);

         smc.setMessage(message);

       } catch (SoapFaultException se){
       //do something here
       //System.out.println("Caught an exception");
       }
       return false;
     }


     return true;
   }




Any help would be much appreciated
Thanks
Hansika

__________________________________________________________________________________________________________________________________

For information about the Standard Bank group visit our web site <www.standardbank.co.za>
__________________________________________________________________________________________________________________________________
        
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relating to the official business of Standard Bank Group Limited is proprietary to the group.
It is confidential, legally privileged and protected by law.
Standard Bank does not own and endorse any other content. Views and opinions are those of the sender unless clearly stated as being that of the group.
The person addressed in the e-mail is the sole authorised recipient. Please notify the sender immediately if it has unintentionally reached you and do not read,
disclose or use the content in any way.
Standard Bank can not assure that the integrity of this communication has been maintained nor that it is free of errors, virus, interception or interference.
___________________________________________________________________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net