You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2002/11/20 17:37:40 UTC
cvs commit: xml-axis/java/src/org/apache/axis/message SOAPFaultCodeBuilder.java SOAPFault.java SOAPFaultBuilder.java
dims 2002/11/20 08:37:40
Modified: java/src/org/apache/axis AxisFault.java Constants.java
java/src/org/apache/axis/message SOAPFault.java
SOAPFaultBuilder.java
Added: java/src/org/apache/axis/message SOAPFaultCodeBuilder.java
Log:
Patch for Bug 14552 - soap 1.2 axis fault patch
from andras.avar@nokia.com
Revision Changes Path
1.62 +131 -4 xml-axis/java/src/org/apache/axis/AxisFault.java
Index: AxisFault.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisFault.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- AxisFault.java 13 Nov 2002 05:04:02 -0000 1.61
+++ AxisFault.java 20 Nov 2002 16:37:40 -0000 1.62
@@ -95,9 +95,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;
@@ -127,7 +129,7 @@
/**
* make a fault
- * @param code fault code which will be pased into the Axis namespace
+ * @param code fault code which will be passed into the Axis namespace
* @param faultString fault string
* @param actor fault actor
* @param details details; if null the current stack trace and classname is
@@ -141,7 +143,7 @@
/**
* make a fault in any namespace
- * @param code fault code which will be pased into the Axis namespace
+ * @param code fault code which will be passed into the Axis namespace
* @param faultString fault string
* @param actor fault actor
* @param details details; if null the current stack trace and classname is
@@ -158,13 +160,38 @@
initFromException(this);
}
+/**
+ * make a fault in any namespace
+ * @param code fault code which will be passed into the Axis namespace
+ * @param subcodes fault subcodes which will be pased into the Axis namespace
+ * @param faultString fault string
+ * @param actor fault actor, same as fault role in SOAP 1.2
+ * @param node which node caused the fault on the SOAP path
+ * @param details details; if null the current stack trace and classname is
+ * inserted into the details.
+ */
+ public AxisFault(QName code, QName[] subcodes, String faultString,
+ String actor, String node, Element[] details) {
+ super (faultString);
+ setFaultCode( code );
+ if (subcodes != null)
+ for (int i = 0; i < subcodes.length; i++)
+ addFaultSubCode( subcodes[i] );
+ setFaultString( faultString );
+ 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 ?
setFaultCodeAsString( Constants.FAULT_SERVER_USER );
initFromException(target);
@@ -178,6 +205,7 @@
public AxisFault(String message)
{
super (message);
+ //TODO: SOAP 1.2 or 1.1 ?
setFaultCodeAsString(Constants.FAULT_SERVER_GENERAL);
setFaultString(message);
initFromException(this);
@@ -189,6 +217,7 @@
public AxisFault()
{
super();
+ //TODO: 1.2 or 1.1 ?
setFaultCodeAsString(Constants.FAULT_SERVER_GENERAL);
initFromException(this);
}
@@ -203,6 +232,7 @@
public AxisFault (String message, Throwable t)
{
super (message, t);
+ //TODO: SOAP 1.2 or 1.1 ?
setFaultCodeAsString(Constants.FAULT_SERVER_GENERAL);
setFaultString(message);
}
@@ -277,10 +307,21 @@
}
}
+ 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
;
}
@@ -299,7 +340,7 @@
* @param code fault code
*/
public void setFaultCodeAsString(String code) {
- faultCode = new QName(Constants.NS_URI_AXIS, code);
+ faultCode = new QName(Constants.URI_SOAP12_ENV, code);
}
/**
@@ -311,6 +352,44 @@
}
/**
+ * This is new in SOAP 1.2, ignored in SOAP 1.1
+ * @return
+ */
+ public void addFaultSubCodeAsString(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[] getFaultSubCodes() {
+ if (faultSubCode == null)
+ return null;
+ QName[] q = new QName[faultSubCode.size()];
+ return (QName[])faultSubCode.toArray(q);
+ }
+
+
+
+
+ /**
* set a fault string;
* @param str new fault string; null is turned into ""
*/
@@ -332,6 +411,22 @@
}
/**
+ * 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();
+ }
+
+ /**
* set the fault actor
* @param actor fault actor
*/
@@ -345,6 +440,38 @@
*/
public String getFaultActor() {
return( faultActor );
+ }
+
+ /**
+ * 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;
}
/**
1.97 +38 -0 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- Constants.java 2 Nov 2002 01:32:05 -0000 1.96
+++ Constants.java 20 Nov 2002 16:37:40 -0000 1.97
@@ -414,6 +414,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" ;
@@ -439,6 +447,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 =
@@ -450,6 +473,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");
1.10 +58 -12 xml-axis/java/src/org/apache/axis/message/SOAPFault.java
Index: SOAPFault.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFault.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SOAPFault.java 8 Oct 2002 03:31:33 -0000 1.9
+++ SOAPFault.java 20 Nov 2002 16:37:40 -0000 1.10
@@ -61,6 +61,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;
@@ -84,21 +85,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);
@@ -109,23 +113,61 @@
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();
+ }
+ }
// get the QName for this faults detail element
Class cls = fault.getClass();
@@ -141,7 +183,11 @@
}
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);
+
// Allow the fault to write its data, if any
axisFault.writeDetails(qname, context);
// Then output any other elements
1.25 +91 -22 xml-axis/java/src/org/apache/axis/message/SOAPFaultBuilder.java
Index: SOAPFaultBuilder.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFaultBuilder.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- SOAPFaultBuilder.java 8 Oct 2002 03:31:33 -0000 1.24
+++ SOAPFaultBuilder.java 20 Nov 2002 16:37:40 -0000 1.25
@@ -60,12 +60,14 @@
import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.Callback;
import org.apache.axis.encoding.CallbackTarget;
+import org.apache.axis.soap.SOAPConstants;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
+import java.util.Vector;
import java.util.HashMap;
import java.util.ArrayList;
import java.lang.reflect.Constructor;
@@ -84,22 +86,34 @@
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 QName faultCode = null;
+ protected QName[] faultSubCode = null;
protected String faultString = null;
protected String faultActor = null;
protected Element[] faultDetails;
+ protected String faultNode = null;
+
+ protected SOAPFaultCodeBuilder code;
protected Class faultClass = null;
protected Object faultData = null;
static {
- fields.put(Constants.ELEM_FAULT_CODE, Constants.XSD_QNAME);
- 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_QNAME);
+ 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,
@@ -145,9 +159,13 @@
*/
private void createFault() {
AxisFault f = null;
+
+ SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
+
if (faultClass != null) {
// Custom fault handling
try {
+
// If we have an element which is fault data, It can be:
// 1. A simple type that needs to be passed in to the constructor
// 2. A complex type that is the exception itself
@@ -171,22 +189,47 @@
// this is to support the <exceptionName> detail
f = (AxisFault) faultClass.newInstance();
}
- f.setFaultCode(faultCode);
+
+ if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
+ f.setFaultCode(code.getFaultCode());
+
+ SOAPFaultCodeBuilder c = code;
+ while ((c = c.getNext()) != null) {
+ f.addFaultSubCode(c.getFaultCode());
+ }
+ }
+
f.setFaultString(faultString);
f.setFaultActor(faultActor);
- f.setFaultDetail(faultDetails);
+ f.setFaultNode(faultNode);
+ f.setFaultDetail(faultDetails);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
// Don't do anything here, since a problem above means
// we'll just fall through and use a plain AxisFault.
}
}
if (f == null) {
+ if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
+ faultCode = code.getFaultCode();
+ if (code.getNext() != null)
+ {
+ Vector v = new Vector();
+
+ SOAPFaultCodeBuilder c = code;
+ while ((c = c.getNext()) != null)
+ v.add(c.getFaultCode());
+
+ faultSubCode = (QName[])v.toArray(new QName[v.size()]);
+ }
+ }
+
f = new AxisFault(faultCode,
+ faultSubCode,
faultString,
faultActor,
+ faultNode,
faultDetails);
}
@@ -201,21 +244,36 @@
throws SAXException
{
SOAPHandler retHandler = null;
+
+ SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
- QName qName = (QName)fields.get(name);
-
+ QName qName = null;
// If we found the type for this field, get the deserializer
// otherwise, if this is the details element, use the special
// SOAPFaultDetailsBuilder handler to take care of custom fault data
+ 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 if (thisQName.equals(Constants.QNAME_FAULTDETAIL_SOAP12))
+ return new SOAPFaultDetailsBuilder(this);
+
+ }
+ } else {
+ qName = (QName)fields_soap11.get(name);
+ if (qName == null && name.equals(Constants.ELEM_FAULT_DETAIL))
+ return new SOAPFaultDetailsBuilder(this);
+ }
+
if (qName != null) {
Deserializer currentDeser = context.getDeserializerForType(qName);
if (currentDeser != null) {
- currentDeser.registerValueTarget(new CallbackTarget(this, name));
+ currentDeser.registerValueTarget(new CallbackTarget(this, new QName(namespace, name)));
}
retHandler = (SOAPHandler) currentDeser;
- } else if (name.equals(Constants.ELEM_FAULT_DETAIL)) {
- retHandler = new SOAPFaultDetailsBuilder(this);
- }
+ }
return retHandler;
}
@@ -250,14 +308,25 @@
*/
public void setValue(Object value, Object hint)
{
- String name = (String)hint;
- if (name.equals(Constants.ELEM_FAULT_CODE)) {
- faultCode = (QName)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)) {
+ faultCode = (QName)value;
+ } else if (local.equals(Constants.ELEM_FAULT_STRING)) {
+ faultString = (String) value;
+ } else if (local.equals(Constants.ELEM_FAULT_ACTOR)) {
+ faultActor = (String) value;
+ }
}
+
}
/**
1.1 xml-axis/java/src/org/apache/axis/message/SOAPFaultCodeBuilder.java
Index: 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);
}
}
}
}