axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14552] New: - soap 1.2 axis fault patch
Date Thu, 14 Nov 2002 12:48:37 GMT
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=14552>.
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=14552

soap 1.2 axis fault patch

           Summary: soap 1.2 axis fault patch
           Product: Axis
           Version: future (enh)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Basic Architecture
        AssignedTo: axis-dev@xml.apache.org
        ReportedBy: andras.avar@nokia.com


I have attached some patches about the SOAP 1.2 compliance of FAULT (also
serializers and deserialziers). Please check them and let me know if you have
any suggestions.

Br,
Andras

*******************************************************************
--- 1_0/org/apache/axis/AxisFault.java	Tue Sep 17 22:38:10 2002
+++ mysoap12/org/apache/axis/AxisFault.java	Thu Nov 14 10:51:17 2002
@@ -90,9 +90,11 @@
         LogFactory.getLog(AxisFault.class.getName());
 
     protected QName     faultCode ;
+    protected Vector    faultSubCode ;
     protected String    faultString = "";
     protected String    faultActor ;
     protected Vector    faultDetails ;  // vector of Element's
+    protected String    faultNode ;
 
     /** SOAP headers which should be serialized with the Fault */
     protected ArrayList faultHeaders = null;
@@ -103,7 +105,7 @@
      * AxisFault.  If the Exception is an InvocationTargetException (which
      * already wraps another Exception), get the wrapped Exception out from
      * there and use that instead of the passed one.
-     */ 
+     */
     public static AxisFault makeFault(Exception e)
     {
         if (e instanceof InvocationTargetException) {
@@ -112,14 +114,17 @@
                 e = (Exception)t;
             }
         }
-        
+
         if (e instanceof AxisFault) {
             return (AxisFault)e;
         }
-        
+
         return new AxisFault(e);
     }
-    
+
+    /**
+     * @deprecated
+     */
     public AxisFault(String code, String str,
                      String actor, Element[] details) {
         super (str);
@@ -131,6 +136,9 @@
             initFromException(this);
     }
 
+    /**
+     * @deprecated
+     */
     public AxisFault(QName code, String str,
                      String actor, Element[] details) {
         super (str);
@@ -142,21 +150,36 @@
             initFromException(this);
     }
 
+    public AxisFault(QName code, QName[] subcodes, String str,
+                     String actor, String node, Element[] details) {
+        super (str);
+        setFaultCode( code );
+        if (subcodes != null)
+            for (int i = 0; i < subcodes.length; i++)
+                addFaultSubCode( subcodes[i] );
+        setFaultString( str );
+        setFaultActor( actor );
+        setFaultNode( node );
+        setFaultDetail( details );
+        if (details == null)
+            initFromException(this);
+    }
+
     /**
      * Wrap an AxisFault around an existing Exception - this is private
      * to force everyone to use makeFault() above, which sanity-checks us.
-     */ 
+     */
     protected AxisFault(Exception target) {
         super ("", target);
-
+        // ? SOAP 1.2 or 1.1 ?
         setFaultCode( Constants.FAULT_SERVER_USER );
-        
         initFromException(target);
     }
 
     public AxisFault(String message)
     {
         super (message);
+        // ? SOAP 1.2 or 1.1 ?
         setFaultCode(Constants.FAULT_SERVER_GENERAL);
         setFaultString(message);
         initFromException(this);
@@ -168,14 +191,16 @@
     public AxisFault()
     {
         super();
-        setFaultCode(Constants.FAULT_SERVER_GENERAL);     
+        // ? SOAP 1.2 or 1.1 ?
+        setFaultCode( Constants.FAULT_SERVER_USER );
         initFromException(this);
     }
 
     public AxisFault (String message, Throwable t)
     {
         super (message, t);
-        setFaultCode(Constants.FAULT_SERVER_GENERAL);
+        // ? SOAP 1.2 or 1.1 ?
+        setFaultCode( Constants.FAULT_SERVER_USER );
         setFaultString(message);
     }
 
@@ -190,34 +215,34 @@
             }
         }
 
-        // Set the exception message (if any) as the fault string 
+        // Set the exception message (if any) as the fault string
         setFaultString( target.toString() );
-        
+
         if (faultDetails == null) faultDetails = new Vector();
 
         Element el;
-        
+
         // If we're derived from AxisFault, then put the exception class
         // into the "exceptionName" element in the details.  This allows
         // us to get back a correct Java Exception class on the other side
         // (assuming they have it available).
-        
+
         if ((target instanceof AxisFault) &&
             (target.getClass() != AxisFault.class)) {
-            el = XMLUtils.StringToElement(Constants.NS_URI_AXIS, 
-                                                  "exceptionName", 
+            el = XMLUtils.StringToElement(Constants.NS_URI_AXIS,
+                                                  "exceptionName",
                                                   target.getClass().getName());
-            
-            faultDetails.add(el);        
+
+            faultDetails.add(el);
         }
-        
-        el =  XMLUtils.StringToElement(Constants.NS_URI_AXIS, 
-                                       "stackTrace", 
+
+        el =  XMLUtils.StringToElement(Constants.NS_URI_AXIS,
+                                       "stackTrace",
                                        JavaUtils.stackToString(target));
 
         faultDetails.add(el);
     }
-    
+
     public void dump()
     {
         log.debug(dumpToString());
@@ -235,11 +260,22 @@
                           + XMLUtils.getInnerXMLString(e);
             }
         }
-        
+
+        String subCodes = new String();
+        if (faultSubCode != null) {
+            for (int i = 0; i < faultSubCode.size(); i++) {
+                subCodes += JavaUtils.LS
+                            + (QName)faultSubCode.elementAt(i);
+
+            }
+        }
+
         return "AxisFault" + JavaUtils.LS
             + " faultCode: " + faultCode + JavaUtils.LS
+            + " faultSubcode: " + subCodes + JavaUtils.LS
             + " faultString: " + faultString + JavaUtils.LS
             + " faultActor: " + faultActor + JavaUtils.LS
+            + " faultNode: " + faultNode + JavaUtils.LS
             + " faultDetail: " + details + JavaUtils.LS
             ;
     }
@@ -249,11 +285,46 @@
     }
 
     public void setFaultCode(String code) {
-        faultCode = new QName(Constants.NS_URI_AXIS, code);
+        faultCode = new QName(Constants.URI_SOAP12_ENV, code);
+    }
+
+    /**
+     * This is new in SOAP 1.2, ignored in SOAP 1.1
+     * @return
+     */
+    public void addFaultSubCode(String code) {
+        if (faultSubCode == null)
+            faultSubCode = new Vector();
+        faultSubCode.add(new QName(Constants.NS_URI_AXIS, code));
+    }
+
+    /**
+     * This is new in SOAP 1.2, ignored in SOAP 1.1
+     * @return
+     */
+    public void addFaultSubCode(QName code) {
+        if (faultSubCode == null)
+            faultSubCode = new Vector();
+        faultSubCode.add(code);
+    }
+
+    /**
+     * This is new in SOAP 1.2, ignored in SOAP 1.1
+     * @return
+     */
+    public void clearFaultSubCodes() {
+        faultSubCode = null;
     }
 
     public QName getFaultCode() {
-        return( faultCode );
+        return(faultCode);
+    }
+
+    public QName[] getFaultSubCodes() {
+        if (faultSubCode == null)
+            return null;
+        QName[] q = new QName[faultSubCode.size()];
+        return (QName[])faultSubCode.toArray(q);
     }
 
     public void setFaultString(String str) {
@@ -268,14 +339,63 @@
         return( faultString );
     }
 
-    public void setFaultActor(String actor) {
-        faultActor = actor ;
+    /**
+     * This is SOAP 1.2 equivalent of {@link #setFaultString(java.lang.String)}
+     * @return
+     */
+    public void setFaultReason(String str) {
+        setFaultString(str);
     }
 
+    /**
+     * This is SOAP 1.2 equivalent of {@link #getFaultString()}
+     * @return
+     */
+    public String getFaultReason() {
+        return getFaultString();
+    }
+
+
     public String getFaultActor() {
         return( faultActor );
     }
 
+    public void setFaultActor(String actor) {
+        faultActor = actor ;
+    }
+
+    /**
+     * This is SOAP 1.2 equivalent of {@link #getFaultActor()}
+     * @return
+     */
+    public String getFaultRole() {
+        return getFaultActor();
+    }
+
+    /**
+     * This is SOAP 1.2 equivalent of {@link #setFaultActor(java.lang.String)}
+     * @return
+     */
+    public void setFaultRole(String role) {
+        setFaultActor(role);
+    }
+
+    /**
+     * This is new in SOAP 1.2
+     * @return
+     */
+    public String getFaultNode() {
+        return( faultNode );
+    }
+
+    /**
+     * This is new in SOAP 1.2
+     * @return
+     */
+    public void setFaultNode(String node) {
+        faultNode = node;
+    }
+
     public void setFaultDetail(Element[] details) {
         if ( details == null ) return ;
         faultDetails = new Vector( details.length );
@@ -309,7 +429,7 @@
             result[i] = (Element) faultDetails.elementAt(i);
         return result;
     }
-    
+
     public void output(SerializationContext context) throws Exception {
 
         SOAPEnvelope envelope = new SOAPEnvelope();



*******************************************************************
--- 1_0/org/apache/axis/Constants.java	Fri Sep 13 22:43:26 2002
+++ mysoap12/org/apache/axis/Constants.java	Tue Nov 12 13:25:53 2002
@@ -95,7 +95,7 @@
     //
     // Default SOAP version
     //
-    public static final SOAPConstants DEFAULT_SOAP_VERSION = 
+    public static final SOAPConstants DEFAULT_SOAP_VERSION =
         SOAPConstants.SOAP11_CONSTANTS;
 
     //
@@ -105,7 +105,7 @@
                                 "http://schemas.xmlsoap.org/soap/envelope/" ;
     public static final String URI_SOAP12_ENV =
                                    "http://www.w3.org/2002/06/soap-envelope";
-    public static final String URI_DEFAULT_SOAP_ENV = 
+    public static final String URI_DEFAULT_SOAP_ENV =
         DEFAULT_SOAP_VERSION.getEnvelopeURI();
 
     public static final String[] URIS_SOAP_ENV = {
@@ -144,7 +144,7 @@
                                 "http://schemas.xmlsoap.org/soap/encoding/" ;
     public static final String URI_SOAP12_ENC =
                                    "http://www.w3.org/2002/06/soap-encoding";
-    public static final String URI_DEFAULT_SOAP_ENC = 
+    public static final String URI_DEFAULT_SOAP_ENC =
         DEFAULT_SOAP_VERSION.getEncodingURI();
 
     public static final String[] URIS_SOAP_ENC = {
@@ -409,6 +409,14 @@
     public static final String ELEM_FAULT_DETAIL = "detail" ;
     public static final String ELEM_FAULT_ACTOR  = "faultactor" ;
 
+    public static final String ELEM_FAULT_CODE_SOAP12 = "Code" ;
+    public static final String ELEM_FAULT_VALUE_SOAP12 = "Value" ;
+    public static final String ELEM_FAULT_SUBCODE_SOAP12 = "Subcode" ;
+    public static final String ELEM_FAULT_REASON_SOAP12 = "Reason" ;
+    public static final String ELEM_FAULT_NODE_SOAP12 = "Node" ;
+    public static final String ELEM_FAULT_ROLE_SOAP12 = "Role" ;
+    public static final String ELEM_FAULT_DETAIL_SOAP12 = "Detail" ;
+
     public static final String ATTR_MUST_UNDERSTAND = "mustUnderstand" ;
     public static final String ATTR_ENCODING_STYLE  = "encodingStyle" ;
     public static final String ATTR_ACTOR           = "actor" ;
@@ -434,6 +442,21 @@
                                   new QName(URI_SOAP11_ENV, "MustUnderstand");
 
 
+    public static final QName FAULT_SOAP12_MUSTUNDERSTAND =
+                                  new QName(URI_SOAP12_ENV, "MustUnderstand");
+
+    public static final QName FAULT_SOAP12_VERSIONMISMATCH =
+                                  new QName(URI_SOAP12_ENV, "VersionMismatch");
+
+    public static final QName FAULT_SOAP12_DATAENCODINGUNKNOW =
+                                  new QName(URI_SOAP12_ENV, "DataEncodingUnknow");
+
+    public static final QName FAULT_SOAP12_SENDER =
+                                  new QName(URI_SOAP12_ENV, "Sender");
+
+    public static final QName FAULT_SOAP12_RECEIVER =
+                                  new QName(URI_SOAP12_ENV, "Receiver");
+
     // QNames
     //////////////////////////////////////////////////////////////////////////
     public static final QName QNAME_FAULTCODE =
@@ -445,6 +468,21 @@
     public static final QName QNAME_FAULTDETAILS =
                                          new QName("", ELEM_FAULT_DETAIL);
 
+    public static final QName QNAME_FAULTCODE_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_CODE_SOAP12);
+    public static final QName QNAME_FAULTVALUE_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_VALUE_SOAP12);
+    public static final QName QNAME_FAULTSUBCODE_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_SUBCODE_SOAP12);
+    public static final QName QNAME_FAULTREASON_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_REASON_SOAP12);
+
+    public static final QName QNAME_FAULTNODE_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_NODE_SOAP12);
+    public static final QName QNAME_FAULTROLE_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_ROLE_SOAP12);
+    public static final QName QNAME_FAULTDETAIL_SOAP12 =
+                                         new QName(URI_SOAP12_ENV,
ELEM_FAULT_DETAIL_SOAP12);
 
     // Define qnames for the all of the XSD and SOAP-ENC encodings
     public static final QName XSD_STRING = new QName(URI_DEFAULT_SCHEMA_XSD,
"string");
@@ -545,7 +583,7 @@
     // When invoked from a servlet, per JAX-RPC, we need  a
     // ServletEndpointContext object.  This is where it lives.
     public static final String MC_SERVLET_ENDPOINT_CONTEXT =
"servletEndpointContext";
-    
+
     public static final String AXIS_VERSION="Axis/1.0";
 
 }

*******************************************************************
--- 1_0/org/apache/axis/Message/SOAPFault.java	Wed Sep 18 18:10:28 2002
+++ mysoap12/org/apache/axis/Message/SOAPFault.java	Mon Nov 11 21:41:32 2002
@@ -60,6 +60,7 @@
 import org.apache.axis.utils.Messages;
 import org.apache.axis.encoding.DeserializationContext;
 import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.soap.SOAPConstants;
 import org.w3c.dom.Element;
 import org.xml.sax.Attributes;
 
@@ -83,21 +84,24 @@
     {
         super(namespace, localName, prefix, attrs, context);
         this.fault = fault;
-        namespaceURI = Constants.URI_SOAP11_ENV;
-        name = Constants.ELEM_FAULT;
     }
 
     public SOAPFault(AxisFault fault)
     {
         this.fault = fault;
-        namespaceURI = Constants.URI_SOAP11_ENV;
-        name = Constants.ELEM_FAULT;
     }
 
     public void outputImpl(SerializationContext context)
         throws IOException
     {
-        context.registerPrefixForURI(prefix, namespaceURI);
+        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);
@@ -108,27 +112,69 @@
             if (axisFault.getFaultCode() != null) {
                 // Do this BEFORE starting the element, so the prefix gets
                 // registered if needed.
-                String faultCode = context.qName2String(axisFault.getFaultCode());
-                context.startElement(Constants.QNAME_FAULTCODE, null);
-                context.writeSafeString(faultCode);
-                context.endElement();
+                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
+                    String faultCode =
context.qName2String(axisFault.getFaultCode());
+                    context.startElement(Constants.QNAME_FAULTCODE_SOAP12, null);
+                    context.startElement(Constants.QNAME_FAULTVALUE_SOAP12, null);
+                    context.writeSafeString(faultCode);
+                    context.endElement();
+                    QName[] subcodes = axisFault.getFaultSubCodes();
+                    if (subcodes != null) {
+                        for (int i = 0; i < subcodes.length; i++) {
+                            faultCode = context.qName2String(subcodes[i]);
+                           
context.startElement(Constants.QNAME_FAULTSUBCODE_SOAP12, null);
+                           
context.startElement(Constants.QNAME_FAULTVALUE_SOAP12, null);
+                            context.writeSafeString(faultCode);
+                            context.endElement();
+                        }
+
+                        for (int i = 0; i < subcodes.length; i++)
+                            context.endElement();
+
+                    }
+                    context.endElement();
+                } else {
+                    String faultCode =
context.qName2String(axisFault.getFaultCode());
+                    context.startElement(Constants.QNAME_FAULTCODE, null);
+                    context.writeSafeString(faultCode);
+                    context.endElement();
+                }
             }
 
             if (axisFault.getFaultString() != null) {
-                context.startElement(Constants.QNAME_FAULTSTRING, null);
+                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS)
+                    context.startElement(Constants.QNAME_FAULTREASON_SOAP12, null);
+                else
+                    context.startElement(Constants.QNAME_FAULTSTRING, null);
                 context.writeSafeString(axisFault.getFaultString());
                 context.endElement();
             }
 
             if (axisFault.getFaultActor() != null) {
-                context.startElement(Constants.QNAME_FAULTACTOR, null);
+                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS)
+                    context.startElement(Constants.QNAME_FAULTROLE_SOAP12, null);
+                else
+                    context.startElement(Constants.QNAME_FAULTACTOR, null);
+
                 context.writeSafeString(axisFault.getFaultActor());
                 context.endElement();
             }
 
+            if (axisFault.getFaultNode() != null) {
+                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
+                    context.startElement(Constants.QNAME_FAULTNODE_SOAP12, null);
+                    context.writeSafeString(axisFault.getFaultNode());
+                    context.endElement();
+                }
+            }
+
             Element[] faultDetails = axisFault.getFaultDetails();
             if (faultDetails != null) {
-                context.startElement(Constants.QNAME_FAULTDETAILS, null);
+                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS)
+                    context.startElement(Constants.QNAME_FAULTDETAIL_SOAP12, null);
+                else
+                    context.startElement(Constants.QNAME_FAULTDETAILS, null);
+
                 for (int i = 0; i < faultDetails.length; i++) {
                     context.writeDOMElement(faultDetails[i]);
                 }
*******************************************************************
--- 1_0/org/apache/axis/Message/SOAPFaultBuilder.java	Sun Jun 23 01:14:04 2002
+++ mysoap12/org/apache/axis/Message/SOAPFaultBuilder.java	Wed Nov 13 21:10:12 2002
@@ -2,7 +2,7 @@
  * The Apache Software License, Version 1.1
  *
  *
- * Copyright (c) 2001 The Apache Software Foundation.  All rights 
+ * Copyright (c) 2001 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
+ *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
  *
  * 4. The names "Axis" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
+ *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache",
@@ -61,6 +61,7 @@
 import org.apache.axis.encoding.Callback;
 import org.apache.axis.encoding.CallbackTarget;
 import org.apache.axis.utils.ClassUtils;
+import org.apache.axis.soap.SOAPConstants;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.w3c.dom.Element;
@@ -71,10 +72,11 @@
 import java.util.HashMap;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.Vector;
 
-/** 
+/**
  * Build a Fault body element.
- * 
+ *
  * @author Sam Ruby (rubys@us.ibm.com)
  * @author Glen Daniels (gdaniels@macromedia.com)
  * @author Tom Jordahl (tomj@macromedia.com)
@@ -83,46 +85,69 @@
 {
     protected SOAPFault element;
     protected DeserializationContext context;
-    static HashMap fields = new HashMap();
-    
+    static HashMap fields_soap11 = new HashMap();
+    static HashMap fields_soap12 = new HashMap();
+
     // Fault data
     protected String faultClassName = null;
-    protected QName faultCode = null;
     protected String faultString = null;
     protected String faultActor = null;
     protected Element[] faultDetails;
+    protected String    faultNode = null;
+    protected QName faultCode;
+    protected Vector faultSubCode = null;
+
+    protected SOAPFaultCodeBuilder code;
 
     static {
-        fields.put(Constants.ELEM_FAULT_CODE, Constants.XSD_STRING);
-        fields.put(Constants.ELEM_FAULT_STRING, Constants.XSD_STRING);
-        fields.put(Constants.ELEM_FAULT_ACTOR, Constants.XSD_STRING);
-        fields.put(Constants.ELEM_FAULT_DETAIL, null);
+        fields_soap11.put(Constants.ELEM_FAULT_CODE, Constants.XSD_STRING);
+        fields_soap11.put(Constants.ELEM_FAULT_STRING, Constants.XSD_STRING);
+        fields_soap11.put(Constants.ELEM_FAULT_ACTOR, Constants.XSD_STRING);
+        fields_soap11.put(Constants.ELEM_FAULT_DETAIL, null);
     }
-    
+
+    static {
+        fields_soap12.put(Constants.ELEM_FAULT_REASON_SOAP12,
Constants.XSD_STRING);
+        fields_soap12.put(Constants.ELEM_FAULT_ROLE_SOAP12, Constants.XSD_STRING);
+        fields_soap12.put(Constants.ELEM_FAULT_NODE_SOAP12, Constants.XSD_STRING);
+        fields_soap12.put(Constants.ELEM_FAULT_DETAIL_SOAP12, null);
+    }
+
     public SOAPFaultBuilder(SOAPFault element,
                             DeserializationContext context) {
         this.element = element;
         this.context = context;
     }
 
+    private void fillAxisFault(AxisFault f) {
+        f.setFaultCode(code.getFaultCode());
+
+        SOAPFaultCodeBuilder c = code;
+        while ((c = c.getNext()) != null) {
+            f.addFaultSubCode(c.getFaultCode());
+        }
+
+        f.setFaultString(faultString);
+        f.setFaultActor(faultActor);
+        f.setFaultNode(faultNode);
+        f.setFaultDetail(faultDetails);
+    }
+
     /**
      * Final call back where we can populate the exception with data.
-     */ 
+     */
     public void endElement(String namespace, String localName,
                            DeserializationContext context)
             throws SAXException {
         super.endElement(namespace, localName, context);
-        
+
         AxisFault f = null;
         if (faultClassName != null) {
             try {
                 Class exClass = ClassUtils.forName(faultClassName);
                 if (AxisFault.class.isAssignableFrom(exClass)) {
                     f = (AxisFault) exClass.newInstance();
-                    f.setFaultCode(faultCode);
-                    f.setFaultString(faultString);
-                    f.setFaultActor(faultActor);
-                    f.setFaultDetail(faultDetails);
+                    fillAxisFault(f);
                 }
             }
             catch (Exception e) {
@@ -132,12 +157,10 @@
         }
 
         if (f == null) {
-            f  = new AxisFault(faultCode, 
-                               faultString, 
-                               faultActor, 
-                               faultDetails);
+            f  = new AxisFault();
+            fillAxisFault(f);
         }
-        
+
         element.setFault(f);
     }
 
@@ -149,22 +172,35 @@
         throws SAXException
     {
         Deserializer currentDeser = null;
-        
-        QName qName = (QName)fields.get(name);
-        
+
+        SOAPConstants soapConstants =
context.getMessageContext().getSOAPConstants();
+
+        QName qName;
+        if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
+            qName = (QName)fields_soap12.get(name);
+            if (qName == null) {
+                QName thisQName = new QName(namespace, name);
+                if (thisQName.equals(Constants.QNAME_FAULTCODE_SOAP12))
+                    return (code = new SOAPFaultCodeBuilder(context));
+            }
+        } else {
+            qName = (QName)fields_soap11.get(name);
+        }
+
         if (qName != null) {
             currentDeser = context.getDeserializerForType(qName);
             if (currentDeser != null) {
-                currentDeser.registerValueTarget(new CallbackTarget(this, name));
+                currentDeser.registerValueTarget(new CallbackTarget(this, new
QName(namespace, name)));
             }
         }
-        
+
         return (SOAPHandler)currentDeser;
     }
 
     public void onEndChild(String namespace, String localName,
                            DeserializationContext context)
             throws SAXException {
+
         if (Constants.ELEM_FAULT_DETAIL.equals(localName)) {
             MessageElement el = context.getCurElement();
             ArrayList children = el.getChildren();
@@ -187,7 +223,7 @@
         }
     }
 
-    /* 
+    /*
      * Defined by Callback.
      * This method gets control when the callback is invoked.
      * @param is the value to set.
@@ -195,21 +231,31 @@
      */
     public void setValue(Object value, Object hint)
     {
-        String name = (String)hint;
-        if (name.equals(Constants.ELEM_FAULT_CODE)) {
-            QName qname = context.getQNameFromString((String)value);
-            if (qname != null) {
-                //??when would QName make sense, this would be app specific
-                faultCode = qname;
-            } else {
-                //?? Where would namespace come from
-                faultCode = new QName("",(String) value);
-            }
-        } else if (name.equals(Constants.ELEM_FAULT_STRING)) {
-            faultString = (String) value;
-        } else if (name.equals(Constants.ELEM_FAULT_ACTOR)) {
-            faultActor = (String) value;
+        String local = ((QName)hint).getLocalPart();
+        if (((QName)hint).getNamespaceURI().equals(Constants.URI_SOAP12_ENV)) {
+            if (local.equals(Constants.ELEM_FAULT_ROLE_SOAP12)) {
+                faultActor = (String) value;
+            } else if (local.equals(Constants.ELEM_FAULT_REASON_SOAP12)) {
+                faultString = (String) value;
+            } else if (local.equals(Constants.ELEM_FAULT_NODE_SOAP12)) {
+                faultNode = (String) value;
+            }
+        } else {
+            if (local.equals(Constants.ELEM_FAULT_CODE)) {
+                QName qname = context.getQNameFromString((String)value);
+                if (qname != null) {
+                    //??when would QName make sense, this would be app specific
+                    faultCode = qname;
+                } else {
+                    //?? Where would namespace come from
+                    faultCode = new QName("",(String) value);
+                }
+            } else if (local.equals(Constants.ELEM_FAULT_STRING)) {
+                faultString = (String) value;
+            } else if (local.equals(Constants.ELEM_FAULT_ACTOR)) {
+                faultActor = (String) value;
+            }
         }
-        
+
     }
 }

Added file SOAPFaultCodeBuilder.java*******************************

/*
 * The Apache Software License, Version 1.1
 *
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Axis" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
package org.apache.axis.message;

import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.Callback;
import org.apache.axis.encoding.CallbackTarget;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
import java.util.Vector;
import javax.xml.namespace.QName;

/**
 * Build a Fault body element.
 *
 * @author Sam Ruby (rubys@us.ibm.com)
 * @author Glen Daniels (gdaniels@macromedia.com)
 * @author Tom Jordahl (tomj@macromedia.com)
 */
public class SOAPFaultCodeBuilder extends SOAPHandler implements Callback
{
    // Fault data
    protected QName faultCode = null;
    protected SOAPFaultCodeBuilder next = null;
    protected DeserializationContext context;

    public SOAPFaultCodeBuilder(DeserializationContext context) {
        this.context = context;
    }

    public QName getFaultCode() {
        return faultCode;
    }

    public SOAPFaultCodeBuilder getNext() {
        return next;
    }

    public SOAPHandler onStartChild(String namespace,
                                    String name,
                                    String prefix,
                                    Attributes attributes,
                                    DeserializationContext context)
        throws SAXException
    {

        QName thisQName = new QName(namespace, name);
        if (thisQName.equals(Constants.QNAME_FAULTVALUE_SOAP12)) {
            Deserializer currentDeser = null;
            currentDeser = context.getDeserializerForType(Constants.XSD_STRING);
            if (currentDeser != null) {
                currentDeser.registerValueTarget(new CallbackTarget(this,
thisQName));
            }
            return (SOAPHandler)currentDeser;
        } else if (thisQName.equals(Constants.QNAME_FAULTSUBCODE_SOAP12)) {
            return (next = new SOAPFaultCodeBuilder(context));
        } else
            return null;
    }

    /*
     * Defined by Callback.
     * This method gets control when the callback is invoked.
     * @param is the value to set.
     * @param hint is an Object that provide additional hint information.
     */
    public void setValue(Object value, Object hint) {
        QName thisQName = (QName)hint;
        if (thisQName.equals(Constants.QNAME_FAULTVALUE_SOAP12)) {
            QName qname = context.getQNameFromString((String)value);
            if (qname != null) {
                faultCode = qname;
            } else {
                faultCode = new QName("",(String) value);
            }
        }
    }
}

Mime
View raw message