Hi all,
I am also facing same issue while throwing SOAPFaultException.
Please help me as soon as possible (please please) 
Its very urgent

the response from webservice should be like this
---------------------------------
- <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
- <SOAP-ENV:Body>
- <soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:x20="http://service.citigroup.com/provider/domainservices/fault/x2005/";>
  <faultcode>soapenv:Client</faultcode>
  <faultstring>Validation Exception</faultstring>
  <faultactor>service.GetSoftwareAssetInfoService</faultactor>
- <detail>
  <x20:ErrorCode>DOMAINSERVICES102</x20:ErrorCode>
  <x20:Description>Validation Error: Invalid content was found starting with
element 'x20:RITSIDList'. One of
'{"http://service.citigroup.com/provider/domainservices/profile/x2004/":SOEIDList}'
is expected.</x20:Description>
  </detail>
  </soapenv:Fault>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>
----------------------------------


----------------------------------
when i test my webservice in SOAPUI, What i got was like this ( here
faultActor & Detail tags are missed)

- <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
- <SOAP-ENV:Body>
- <soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:x20="http://service.citigroup.com/provider/domainservices/fault/x2005/";>
  <faultcode>soapenv:Client</faultcode>
  <faultstring>Validation Exception</faultstring>
  </soapenv:Fault>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>
------------------------------------

 
My code for the webservice for throwing SOAPfaultException is given
below........

import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;

import com.citi.soa.common.DomainServicesConstants;
import com.citi.soa.common.DomainServicesErrorCodes;
import com.citigroup.domainservices.common.util.PropertiesReader;

public class TestSoapExp {

        public static javax.xml.ws.soap.SOAPFaultException getException(String
sFaultCode, String sFaultString, String sFaultActor,  String sErrorCode)
         {
                System.out.println("DomainServicesFaultHandler :: 
getException(sFaultCode,
sFaultActor, sFaultString, sErrorCode) :: Entry");
        //to resolve the problem of SAAJ
       
System.setProperty("javax.xml.soap.MessageFactory","com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl");
       
System.setProperty("javax.xml.soap.SOAPConnectionFactory","weblogic.wsee.saaj.SOAPConnectionFactoryImpl");
 
        QName faultCode = new
QName("http://schemas.xmlsoap.org/soap/envelope/",sFaultCode);
        javax.xml.soap.SOAPFault fault = null;
        SOAPMessage faultMessage = null;
        try
        {
                MessageFactory msgFactory = MessageFactory.newInstance();
                System.out.println("the msgFactory is :: "+msgFactory);
                faultMessage = msgFactory.createMessage();
            System.out.println("the fault message is :: "+faultMessage);
            SOAPPart part = faultMessage.getSOAPPart();
            System.out.println("the sopa part is :: "+part);
                SOAPEnvelope envelope = part.getEnvelope();
                System.out.println("the enevelope is :: "+envelope);
                SOAPBody body = envelope.getBody();
                System.out.println("the body is :: "+body);
 
                System.out.println("Value of fault before fault = 
body.addFault();
:: " + fault);
                fault = body.addFault();
                System.out.println("Value of fault after fault = 
body.addFault();
:: " + fault);
 
                System.out.println("before setting value Value of
fault.getFaultCode is :: "+fault.getFaultCode());
                try{
                        fault.setFaultCode(faultCode);
            }catch(Exception e){
                System.out.println("Exception while setting faultCode :: " +
e);
            }
            System.out.println("Value of fault.getFaultCode is ::
"+fault.getFaultCode());
            fault.setFaultString(sFaultString);
            System.out.println("Value of fault.getFaultString is ::
"+fault.getFaultString());
            fault.setFaultActor(sFaultActor);
            System.out.println("Value of fault.getFaultActor is ::
"+fault.getFaultActor());
 
            Detail faultDetail = fault.addDetail();
            System.out.println("vaule of faultDeatil :: " + faultDetail);
            SOAPElement e1 = faultDetail.addChildElement("ErrorCode");
            e1.addTextNode(sErrorCode);
            SOAPElement e2 = faultDetail.addChildElement("Description");
            e2.addTextNode(PropertiesReader.getPropertyValue(sErrorCode));
 
            System.out.println("errorcode is e1.getTextContent()" +
e1.getTextContent());
            System.out.println("errorDescr is e2.getTextContent()" +
e2.getTextContent());
 
            System.out.println("befor savechanges FaultMessage Is :: " +
faultMessage);
            faultMessage.saveChanges();
            System.out.println("befor savechanges FaultMessage Is :: " +
faultMessage);
 
            faultMessage.writeTo(System.out);
 
           
System.out.println(faultMessage.getSOAPPart().getEnvelope().getBody().getFault().getFaultActor()+"***********");
 
            System.out.println("value of fault :: " + fault);
            System.out.println("value of body :: " + body);
            System.out.println("value of envelop :: " + envelope);
            System.out.println("value of part :: " + part);
            System.out.println("value of faultMessage :: " + faultMessage);
            System.out.println("value of msgFactory :: " + msgFactory);
 
            System.out.println("value of fault before :: " +
fault.getFaultActor());
            System.out.println("value of fault before :: " +
fault.getFaultString());
            System.out.println("value of fault before  :: " +
fault.getFaultCode());
            String s = faultMessage.getContentDescription();
            System.out.println("Message content :: " + s);
            fault =
faultMessage.getSOAPPart().getEnvelope().getBody().getFault();
            System.out.println("value of fault :: " +
fault.getFaultActor());
            System.out.println("value of fault :: " +
fault.getFaultString());
            System.out.println("value of fault :: " + fault.getFaultCode());
 
        }catch(Exception ex)
        {
                 System.out.println("DomainServicesFaultHandler ::
getException(sFaultCode, sFaultActor, sFaultString, sErrorCode) = "+ex);
                }
        System.out.println("DomainServicesFaultHandler ::
getException(sFaultCode, sFaultActor, sFaultString, sErrorCode) :: Exit");
 

        return new javax.xml.ws.soap.SOAPFaultException(fault);
         }
        
        public static void main(String args[])
        {
                System.out.println("entering in to category for throwing
exception.......before throwing..........................");
                try{
                        javax.xml.ws.soap.SOAPFaultException retExp = 
getException(DomainServicesConstants.SOAP_FAULT_SERVER,
                        DomainServicesConstants.SYSTEM_EXCEPTION,
                        DomainServicesConstants.PROFILE_PROCESS,
                        
DomainServicesErrorCodes.SUPPLIER_MASTER_INVALID_INPUTS);
                        System.out.println("returned exp :: " + retExp);
                        throw retExp;
        
                }catch(Exception e)
                {
                        System.out.println("exception occurred :: " + e);
                        System.out.println("exception occurred :: " + 
e.getMessage());
                        System.out.println("exception occurred :: " + 
e.getCause());
                        System.out.println("exception occurred :: " + 
e.getStackTrace());
        
                }
        }
}


when i run this code as stand alone & it prints proper output.
Please help me.

Thanks a lot in advance.




Davide Gesino wrote:
> 
> I am trying to throw a SOAPFaultException from an handler. Anyway I have
> some weird error in what I get back.
> I have tried the same code on java 6 without CXF and the handler chain
> works differently (with java 1.6 works fine)
> 
> This is the handleMessage on my custom SOAPHandler (the way I fill the
> SOAPFault is taken from the SUN tutorial):
> 
> 1) WITH JAVA 6:
> 
> public boolean handleMessage(SOAPMessageContext ctx) {
>               Boolean outboundProperty = (Boolean) ctx
>                               .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
> 
>               if (!outboundProperty) {
>                       SOAPMessage msg = ctx.getMessage();
>                       SOAPBody body;
>                       try {
>                               body = msg.getSOAPBody();
> 
>                               SOAPFault fault = body.addFault();
>                               QName faultName = new 
> QName(SOAPConstants.URI_NS_SOAP_ENVELOPE,
>                                               "Server");
>                               fault.setFaultCode(faultName);
>                               fault.setFaultActor("http://gizmos.com/orders";);
>                               fault.setFaultString("Server not responding");
> 
>                               Detail detail = fault.addDetail();
> 
>                               QName entryName = new 
> QName("http://gizmos.com/orders/";,
>                                               "order", "PO");
>                               DetailEntry entry = 
> detail.addDetailEntry(entryName);
>                               entry.addTextNode("Quantity element does not 
> have a value");
> 
>                               QName entryName2 = new 
> QName("http://gizmos.com/orders/";,
>                                               "order", "PO");
>                               DetailEntry entry2 = 
> detail.addDetailEntry(entryName2);
>                               entry2.addTextNode("Incomplete address: no zip 
> code");
> 
>                               throw new SOAPFaultException(fault);
> 
>                       } catch (SOAPException e) {
>                               // TODO Auto-generated catch block
>                               e.printStackTrace();
>                       }
>               }
> 
>               return true;
>       }
> 
> 
> and here is the log of the message sent back to the client. The SOAPFault
> is populated correctly.
> 
> <soapenv:Fault>
>       <faultcode>soapenv:Server</faultcode>
>       <faultstring>Server not responding</faultstring>
>       <faultactor>http://gizmos.com/orders</faultactor>
>       <detail>
>         <PO:order xmlns:PO="http://gizmos.com/orders/";>Quantity element
> does not have a value</PO:order>
>         <PO:order xmlns:PO="http://gizmos.com/orders/";>Incomplete address:
> no zip code</PO:order>
>       </detail>
>   </soapenv:Fault>
> 
>  2) WITH CXF + Java 5:
> 
> I have the same handler doing the same work. debugging the SOAPFault seems
> to be populated correctly:
> Anyway logging the answer here is what I get.
> 
> 
>  <soap:Fault>
>       <faultcode>soap:Server</faultcode>
>       <faultstring>Server not responding</faultstring>
> </soap:Fault>
> 
> The actor and expecially the details are missing. 
> 
> Debugging I see a possible symptom in the code (maybe): the toString() of
> the Fault (and of the Details implementation) is:
> 
> [soap:Fault: null]
> [detail:null]
> 
> This is the implementation:
> 
>  /** NON-DOM method for debugging convenience. */
>     public String toString() {
>         return "["+getNodeName()+": "+getNodeValue()+"]";
>     }
> 
> so the node value seems to be null.
> 
> In the SOAP11FaultOutInterceptor I havethe following:
> 
> public void handleMessage(SoapMessage message) throws Fault {
>         message.put(org.apache.cxf.message.Message.RESPONSE_CODE, new
> Integer(500));
> 
>         XMLStreamWriter writer =
> message.getContent(XMLStreamWriter.class);
>         Fault f = (Fault) message.getContent(Exception.class);
> 
>         SoapFault fault = SoapFault.createFault(f, message.getVersion());
> 
> inspecting the 'f' variable I see that the detail member is null.
> Am i missing something of it is a possible bug? 
> Thanks a lot.
> 
> Davide
> 
> 

-- 
View this message in context: 
http://www.nabble.com/SOAPFaultException%2C-weird-error-in-JAX-WS-Handlers-tp15269025p23613866.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to