1 22 package org.jboss.test.webservice.exception; 23 24 import javax.xml.namespace.QName ; 25 import javax.xml.rpc.JAXRPCException ; 26 import javax.xml.rpc.handler.GenericHandler ; 27 import javax.xml.rpc.handler.MessageContext ; 28 import javax.xml.rpc.handler.soap.SOAPMessageContext ; 29 import javax.xml.soap.SOAPException ; 30 import javax.xml.soap.SOAPFault ; 31 import javax.xml.soap.SOAPMessage ; 32 33 public class ServerHandler extends GenericHandler 34 { 35 36 public QName [] getHeaders() 37 { 38 return new QName [] {}; 39 } 40 41 public boolean handleFault(MessageContext msgContext) 44 { 45 try 46 { 47 SOAPMessage soapMessage = ((SOAPMessageContext )msgContext).getMessage(); 48 49 SOAPFault soapFault = soapMessage.getSOAPBody().getFault(); 50 String faultString = soapFault.getFaultString(); 51 if (!faultString.equals("Don't worry it's just a test") && !faultString.equals("org.jboss.test.webservice.exception.UserException")) 52 throw new JAXRPCException ("Unexpected fault string: " + faultString); 53 54 return true; 55 56 } 57 catch (SOAPException e) 58 { 59 throw new JAXRPCException (e.toString(), e); 60 } 61 } 62 } 63 | Popular Tags |