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/03/12 20:04:21 UTC

cvs commit: xml-axis/java/src/org/apache/axis SOAPPart.java

gdaniels    02/03/12 11:04:21

  Modified:    java/samples/transport/tcp TCPListener.java
               java/src/org/apache/axis SOAPPart.java
  Log:
  Throw faults which occur during serialization, instead of making the
  SOAPPart's value equal to the serialized fault.
  
  Revision  Changes    Path
  1.17      +16 -2     xml-axis/java/samples/transport/tcp/TCPListener.java
  
  Index: TCPListener.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/TCPListener.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TCPListener.java	19 Feb 2002 17:38:18 -0000	1.16
  +++ TCPListener.java	12 Mar 2002 19:04:21 -0000	1.17
  @@ -265,8 +265,22 @@
               /* Send it back along the wire...  */
               /***********************************/
               msg = msgContext.getResponseMessage();
  -            String response = (String) msg.getSOAPPart().getAsString();
  -            if (msg == null) response="No data";
  +            String response = null;
  +            if (msg == null) {
  +                response="No data";
  +            } else {
  +                try {
  +                    response = (String) msg.getSOAPPart().getAsString();
  +                } catch (AxisFault fault) {
  +                    msg = new Message(fault);
  +                    try {
  +                        response = (String)msg.getSOAPPart().getAsString();
  +                    } catch (AxisFault fault2) {
  +                        response = fault2.dumpToString();
  +                    }
  +                }
  +            }
  +
               try {
                   OutputStream buf = new BufferedOutputStream(socket.getOutputStream());
                   // this should probably specify UTF-8, but for now, for Java interop,
  
  
  
  1.15      +9 -13     xml-axis/java/src/org/apache/axis/SOAPPart.java
  
  Index: SOAPPart.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SOAPPart.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SOAPPart.java	27 Feb 2002 13:06:11 -0000	1.14
  +++ SOAPPart.java	12 Mar 2002 19:04:21 -0000	1.15
  @@ -186,8 +186,12 @@
        * also cache the byte[] form of the SOAPPart.
        */
       public int getContentLength() {
  -        byte[] bytes = this.getAsBytes();
  -        return bytes.length;
  +        try {
  +            byte[] bytes = this.getAsBytes();
  +            return bytes.length;
  +        } catch (AxisFault fault) {
  +            return 0;  // ?
  +        }
       }
       /**
        * This set the SOAP Envelope for this part. 
  @@ -257,7 +261,7 @@
        * Get the contents of this Part (not the headers!), as a byte
        * array.  This will force buffering of the message.
        */
  -    public byte[] getAsBytes() {
  +    public byte[] getAsBytes() throws AxisFault {
       log.debug( "Enter: SOAPPart::getAsBytes" );
           if ( currentForm == FORM_BYTES ) {
               log.debug( "Exit: SOAPPart::getAsBytes" );
  @@ -329,7 +333,7 @@
        * Get the contents of this Part (not the headers!), as a String.
        * This will force buffering of the message.
        */
  -    public String getAsString() {
  +    public String getAsString() throws AxisFault {
           log.debug( "Enter: SOAPPart::getAsString" );
           if ( currentForm == FORM_STRING ) {
               log.debug( "Exit: SOAPPart::getAsString, currentMessage is "+
  @@ -375,15 +379,7 @@
               try {
                   env.output(new SerializationContextImpl(writer, getMessage().getMessageContext()));
               } catch (Exception e) {
  -                AxisFault fault = AxisFault.makeFault(e);
  -                // Start over, write the fault...
  -                writer = new StringWriter();
  -                try {
  -                    fault.output(new SerializationContextImpl(writer, getMessage().getMessageContext()));
  -                } catch (Exception ex) {
  -                    // OK, now we're *really* in trouble.
  -                    return null;
  -                }
  +                throw AxisFault.makeFault(e);
               }
               setCurrentMessage(writer.getBuffer().toString(), FORM_STRING);
               return (String)currentMessage;