DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20647>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20647

 Create Custom SOAP Fault(SAAJ spec violation)

           Summary:  Create Custom SOAP Fault(SAAJ spec violation)
           Product: Axis
           Version: 1.1rc2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I want to create a custom SOAP Fault filling the FaultCode,FaultString  and 
detail myself.
But it seems the Axis SOAPFault implementation forces me to use the 
AxisFault, to create SoapFault.
which is not a clean way of doing the creation.

See the code snippet

<Snippet>
public void testquick() throws Exception {
        MessageFactory msgfactory = MessageFactory.newInstance();
        SOAPFactory factory = SOAPFactory.newInstance();

        SOAPMessage outputmsg = msgfactory.createMessage();
        String valueCode = "faultcode";
        String valueString = "faultString";

        SOAPFault fault =
            outputmsg.getSOAPPart().getEnvelope().getBody().addFault();
        fault.setFaultCode(valueCode);
        fault.setFaultString(valueString);


        Detail d;

        d = fault.addDetail();

        d.addDetailEntry(factory.createName("Hello"));

        if (outputmsg != null) {
            if (outputmsg.saveRequired()) {
                outputmsg.saveChanges();
            }
            outputmsg.writeTo(System.out);
        }
    }
</Snippet>

<output>
.<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:faultcode</faultcode>
   <faultstring>faultString</faultstring>
   <faultactor></faultactor>
   <detail/>  <-------------------------------Detail Missing. , added a 
Hello element.
  </soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
</output>

I think this is because of the serialization code, which only uses 
AxisFault.
No reference to current detail

<codesnippet>
public void outputImpl(SerializationContext context)
            throws IOException
    {
        SOAPConstants soapConstants = context.getMessageContext() == null ?
                                        SOAPConstants.SOAP11_CONSTANTS :
                                        
context.getMessageContext().getSOAPConstants();

        namespaceURI = soapConstants.getEnvelopeURI();
        name = Constants.ELEM_FAULT;

        context.registerPrefixForURI(prefix, 
soapConstants.getEnvelopeURI());
        context.startElement(new QName(this.getNamespaceURI(),
                                       this.getName()),
                             attributes);

        // XXX - Can fault be anything but an AxisFault here?
        if (fault instanceof AxisFault) {

</codesnippet>

Is it a Bug and violation of SAAJ Spec.

Reply via email to