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 gd...@apache.org on 2002/09/17 22:38:10 UTC

cvs commit: xml-axis/java/src/org/apache/axis/encoding/ser BeanSerializer.java

gdaniels    2002/09/17 13:38:10

  Modified:    java/test/chains TestChainFault.java
               java/src/org/apache/axis/handlers/soap SOAPService.java
               java/src/org/apache/axis SimpleChain.java AxisFault.java
               java/src/org/apache/axis/encoding
                        SerializationContextImpl.java
               java/src/org/apache/axis/components/compiler
                        CompilerFactory.java
               java/src/org/apache/axis/encoding/ser BeanSerializer.java
  Log:
  AxisFaults now have a place to put headers which are associated with
  the fault.  Change SOAPService to use this facility to insert its
  "misunderstood" headers, and change the fault handling in
  SimpleChain to simply let the caught Fault serialize itself (including the
  aforementioned headers).
  
  Revision  Changes    Path
  1.3       +2 -2      xml-axis/java/test/chains/TestChainFault.java
  
  Index: TestChainFault.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/chains/TestChainFault.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestChainFault.java	24 Aug 2002 23:27:30 -0000	1.2
  +++ TestChainFault.java	17 Sep 2002 20:38:09 -0000	1.3
  @@ -67,6 +67,7 @@
   import org.apache.axis.handlers.BasicHandler;
   import org.apache.axis.MessageContext;
   import org.apache.axis.AxisFault;
  +import org.apache.axis.server.AxisServer;
   
   /**
   * Used to verify that Faults are processed properly in the Handler chain
  @@ -94,8 +95,7 @@
           private int hcount = 0;
   
           public TestMessageContext() {
  -            // A null engine is good enough for this test
  -            super(null);
  +            super(new AxisServer());
           }
   
           public void incCount() {
  
  
  
  1.82      +14 -14    xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
  
  Index: SOAPService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- SOAPService.java	17 Sep 2002 15:42:44 -0000	1.81
  +++ SOAPService.java	17 Sep 2002 20:38:09 -0000	1.82
  @@ -58,7 +58,6 @@
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
   import org.apache.axis.Handler;
  -import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.SimpleTargetedChain;
   import org.apache.axis.attachments.Attachments;
  @@ -72,7 +71,6 @@
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHeaderElement;
   import org.apache.axis.providers.BasicProvider;
  -import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.LockableHashtable;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.utils.XMLUtils;
  @@ -194,15 +192,15 @@
               boolean doMisunderstoodHeaders = true;
   
               if (misunderstoodHeaders != null) {
  -                // !!! If SOAP 1.2, insert misunderstood fault header here
  +                AxisFault fault =
  +                        new AxisFault(Constants.FAULT_MUSTUNDERSTAND,
  +                                      null,
  +                                      null, null);
  +
                   StringBuffer whatWasMissUnderstood= new StringBuffer(256);
  +
  +                // !!! If SOAP 1.2, insert misunderstood fault headers here
                   if (doMisunderstoodHeaders) {
  -                    Message respMsg = msgContext.getResponseMessage();
  -                    if (respMsg == null) {
  -                        respMsg = new Message(new SOAPEnvelope());
  -                        msgContext.setResponseMessage(respMsg);
  -                    }
  -                    env = respMsg.getSOAPEnvelope();
                       enum = misunderstoodHeaders.elements();
                       while (enum.hasMoreElements()) {
                           SOAPHeaderElement badHeader = (SOAPHeaderElement)enum.
  @@ -211,7 +209,7 @@
                                                      badHeader.getName());
   
                           if(whatWasMissUnderstood.length() != 0) whatWasMissUnderstood.append(", ");
  -                        whatWasMissUnderstood.append( badQName.toString() );                           
  +                        whatWasMissUnderstood.append( badQName.toString() );
   
                           SOAPHeaderElement newHeader = new
                               SOAPHeaderElement(Constants.URI_SOAP12_FAULT,
  @@ -220,13 +218,15 @@
                                                  Constants.ATTR_QNAME,
                                                  badQName);
   
  -                        env.addHeader(newHeader);
  +                        fault.addHeader(newHeader);
                       }
                   }
   
  -                throw new AxisFault(Constants.FAULT_MUSTUNDERSTAND,
  -                                    Messages.getMessage("noUnderstand00", whatWasMissUnderstood.toString()),
  -                                    null, null);
  +                fault.setFaultString(
  +                        Messages.getMessage("noUnderstand00",
  +                                            whatWasMissUnderstood.toString()));
  +
  +                throw fault;
               }
           }
       }
  
  
  
  1.52      +1 -5      xml-axis/java/src/org/apache/axis/SimpleChain.java
  
  Index: SimpleChain.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleChain.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- SimpleChain.java	9 Sep 2002 17:03:22 -0000	1.51
  +++ SimpleChain.java	17 Sep 2002 20:38:09 -0000	1.52
  @@ -156,11 +156,7 @@
           } catch( AxisFault f ) {
              // Attach the fault to the response message; enabling access to the
              // fault details while inside the handler onFault methods.
  -            SOAPEnvelope env = new SOAPEnvelope();
  -            SOAPFault faultEl = new SOAPFault(f);
  -            env.clearBody();
  -            env.addBodyElement(faultEl);
  -            Message respMsg = new Message(env);
  +            Message respMsg = new Message(f);
               msgContext.setResponseMessage(respMsg);
               while( --i >= 0 )
                   ((Handler) handlers.elementAt( i )).onFault( msgContext );
  
  
  
  1.58      +32 -3     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.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- AxisFault.java	12 Aug 2002 22:23:54 -0000	1.57
  +++ AxisFault.java	17 Sep 2002 20:38:09 -0000	1.58
  @@ -58,6 +58,7 @@
   import org.apache.axis.encoding.SerializationContext;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPFault;
  +import org.apache.axis.message.SOAPHeaderElement;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.XMLUtils;
   
  @@ -68,10 +69,11 @@
   import org.w3c.dom.Element;
   import org.w3c.dom.Text;
   
  -import java.io.ByteArrayOutputStream;
   import java.io.PrintStream;
   import java.lang.reflect.InvocationTargetException;
   import java.util.Vector;
  +import java.util.ArrayList;
  +import java.util.Iterator;
   
   import javax.xml.namespace.QName;
   
  @@ -92,6 +94,9 @@
       protected String    faultActor ;
       protected Vector    faultDetails ;  // vector of Element's
   
  +    /** SOAP headers which should be serialized with the Fault */
  +    protected ArrayList faultHeaders = null;
  +
       /**
        * Make an AxisFault based on a passed Exception.  If the Exception is
        * already an AxisFault, simply use that.  Otherwise, wrap it in an
  @@ -309,10 +314,17 @@
   
           SOAPEnvelope envelope = new SOAPEnvelope();
   
  -        SOAPFault fault =
  -                                new SOAPFault(this);
  +        SOAPFault fault = new SOAPFault(this);
           envelope.addBodyElement(fault);
   
  +        // add any headers we need
  +        if (faultHeaders != null) {
  +            for (Iterator i = faultHeaders.iterator(); i.hasNext();) {
  +                SOAPHeaderElement header = (SOAPHeaderElement) i.next();
  +                envelope.addHeader(header);
  +            }
  +        }
  +
           envelope.output(context);
       }
   
  @@ -328,5 +340,22 @@
       public void printStackTrace(java.io.PrintWriter pw) {
           pw.println(dumpToString());
           super.printStackTrace(pw);
  +    }
  +
  +    /**
  +     * Add a SOAP header which should be serialized along with the
  +     * fault.
  +     *
  +     * @param header a SOAPHeaderElement containing some fault-relevant stuff
  +     */
  +    public void addHeader(SOAPHeaderElement header) {
  +        if (faultHeaders == null) {
  +            faultHeaders = new ArrayList();
  +        }
  +        faultHeaders.add(header);
  +    }
  +
  +    public void clearHeaders() {
  +        faultHeaders = null;
       }
   };
  
  
  
  1.69      +0 -1      xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- SerializationContextImpl.java	17 Sep 2002 11:53:29 -0000	1.68
  +++ SerializationContextImpl.java	17 Sep 2002 20:38:09 -0000	1.69
  @@ -69,7 +69,6 @@
   import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.attachments.Attachments;
   import org.apache.axis.client.Call;
  -import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.Mapping;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.utils.NSStack;
  
  
  
  1.6       +0 -1      xml-axis/java/src/org/apache/axis/components/compiler/CompilerFactory.java
  
  Index: CompilerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/compiler/CompilerFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CompilerFactory.java	9 Sep 2002 17:03:29 -0000	1.5
  +++ CompilerFactory.java	17 Sep 2002 20:38:10 -0000	1.6
  @@ -56,7 +56,6 @@
   package org.apache.axis.components.compiler;
   
   import org.apache.axis.AxisProperties;
  -import org.apache.axis.utils.ClassUtils;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.Messages;
   
  
  
  
  1.54      +0 -1      xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- BeanSerializer.java	9 Sep 2002 17:03:23 -0000	1.53
  +++ BeanSerializer.java	17 Sep 2002 20:38:10 -0000	1.54
  @@ -64,7 +64,6 @@
   import org.apache.axis.encoding.Serializer;
   import org.apache.axis.utils.BeanPropertyDescriptor;
   import org.apache.axis.utils.BeanUtils;
  -import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.wsdl.fromJava.Types;