axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/handlers/soap SOAPService.java
Date Sun, 25 Aug 2002 14:00:03 GMT
rubys       2002/08/25 07:00:03

  Modified:    java/src/org/apache/axis Message.java SOAPPart.java
               java/src/org/apache/axis/attachments Attachments.java
                        AttachmentsImpl.java
               java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
                        WSDDService.java
               java/src/org/apache/axis/handlers/soap SOAPService.java
  Log:
  Rough in support for streaming of output
  
  Revision  Changes    Path
  1.85      +16 -6     xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- Message.java	23 Aug 2002 19:07:19 -0000	1.84
  +++ Message.java	25 Aug 2002 14:00:02 -0000	1.85
  @@ -72,6 +72,7 @@
   import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
   import java.io.IOException;
  +import java.io.OutputStreamWriter;
   import java.util.Iterator;
   
   /**
  @@ -376,9 +377,18 @@
       }
   
       public String getContentType(SOAPConstants sc) throws AxisFault {
  -        //Force serialization if it hasn't happend it.
  -        //Rick Rineholt fix this later.
  -        mSOAPPart.getAsBytes();
  +
  +        int sendType = Attachments.SEND_TYPE_NOTSET;
  +        if (msgContext.getService() != null) {
  +            sendType = msgContext.getService().getSendType();
  +        }
  +
  +        if (sendType != Attachments.SEND_TYPE_NONE) {
  +            //Force serialization if it hasn't happend it.
  +            //Rick Rineholt fix this later.
  +            mSOAPPart.getAsBytes();
  +        }
  +
           String ret = sc.getContentType();
           if (mAttachments != null && 0 != mAttachments.getAttachmentCount()) {
               ret = mAttachments.getContentType();
  @@ -388,8 +398,6 @@
   
       //This will have to give way someday to HTTP Chunking but for now kludge.
       public long getContentLength() throws org.apache.axis.AxisFault {
  -        //Force serialization if it hasn't happend it.
  -        //Rick Rineholt fix this later.
           long ret = mSOAPPart.getAsBytes().length;
           if (mAttachments != null && 0 < mAttachments.getAttachmentCount()) {
               ret = mAttachments.getContentLength();
  @@ -417,7 +425,9 @@
            //Do it the old fashion way.
           if (mAttachments == null || 0 == mAttachments.getAttachmentCount()) {
               try {
  -                os.write(mSOAPPart.getAsBytes());
  +                OutputStreamWriter writer = new OutputStreamWriter(os,"UTF-8");
  +                mSOAPPart.writeTo(writer);
  +                writer.flush();
               } catch (java.io.IOException e) {
                   log.error(JavaUtils.getMessage("javaIOException00"), e);
               }
  
  
  
  1.41      +27 -7     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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- SOAPPart.java	21 Aug 2002 13:42:13 -0000	1.40
  +++ SOAPPart.java	25 Aug 2002 14:00:02 -0000	1.41
  @@ -244,12 +244,32 @@
       }
   
       /**
  -     * Write out the contents & headers to out.
  -     * TODO: actually write headers!  probably also add parameter
  -     * to indicate whether to bother....
  +     * Write the contents to the specified writer.
        */
  -    public void writeTo(OutputStream out) throws IOException {
  -        out.write(this.getAsBytes());
  +    public void writeTo(Writer writer) throws IOException {
  +
  +        if ( currentForm == FORM_FAULT ) {
  +            AxisFault env = (AxisFault)currentMessage;
  +            try {
  +                env.output(new SerializationContextImpl(writer, getMessage().getMessageContext()));
  +            } catch (Exception e) {
  +                log.error(JavaUtils.getMessage("exception00"), e);
  +                throw env;
  +            }
  +            return;
  +        }
  +
  +        if ( currentForm == FORM_SOAPENVELOPE ) {
  +            SOAPEnvelope env = (SOAPEnvelope)currentMessage;
  +            try {
  +                env.output(new SerializationContextImpl(writer, getMessage().getMessageContext()));
  +            } catch (Exception e) {
  +                throw AxisFault.makeFault(e);
  +            }
  +            return;
  +        }
  +
  +        writer.write(this.getAsString());
           // easy, huh?
       }
   
  @@ -396,7 +416,7 @@
               StringWriter writer = new StringWriter();
               AxisFault env = (AxisFault)currentMessage;
               try {
  -                env.output(new SerializationContextImpl(writer, getMessage().getMessageContext()));
  +                this.writeTo(writer);
               } catch (Exception e) {
                   log.error(JavaUtils.getMessage("exception00"), e);
                   return null;
  @@ -410,7 +430,7 @@
               StringWriter writer = new StringWriter();
               SOAPEnvelope env = (SOAPEnvelope)currentMessage;
               try {
  -                env.output(new SerializationContextImpl(writer, getMessage().getMessageContext()));
  +                this.writeTo(writer);
               } catch (Exception e) {
                   throw AxisFault.makeFault(e);
               }
  
  
  
  1.12      +4 -1      xml-axis/java/src/org/apache/axis/attachments/Attachments.java
  
  Index: Attachments.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/Attachments.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Attachments.java	19 Jul 2002 10:30:57 -0000	1.11
  +++ Attachments.java	25 Aug 2002 14:00:02 -0000	1.12
  @@ -242,7 +242,10 @@
       /** Use the DIME attatchment type. */
       public final int  SEND_TYPE_DIME= 3; //use dime;
   
  -    final int SEND_TYPE_MAX = 3;
  +    /** Use the DIME attatchment type. */
  +    public final int  SEND_TYPE_NONE= 4; //don't send as attachments
  +
  +    final int SEND_TYPE_MAX = 4;
   
       /** The default attatchment type. MIME */
       final int SEND_TYPE_DEFAULT = SEND_TYPE_MIME; 
  
  
  
  1.31      +12 -0     xml-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java
  
  Index: AttachmentsImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- AttachmentsImpl.java	12 Aug 2002 22:28:57 -0000	1.30
  +++ AttachmentsImpl.java	25 Aug 2002 14:00:02 -0000	1.31
  @@ -643,4 +643,16 @@
       public int getSendType(){
         return sendtype;
       }
  +
  +    /**
  +     * Determine how an object typically sent as attachments are to
  +     * be represented.
  +     */
  +
  +    public static int getSendType(String value) {
  +        if (value.equalsIgnoreCase("MIME")) return SEND_TYPE_MIME;
  +        if (value.equalsIgnoreCase("DIME")) return SEND_TYPE_DIME;
  +        if (value.equalsIgnoreCase("NONE")) return SEND_TYPE_NONE;
  +        return SEND_TYPE_NOTSET;
  +    }
   }
  
  
  
  1.21      +1 -0      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java
  
  Index: WSDDConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- WSDDConstants.java	17 Jul 2002 20:27:28 -0000	1.20
  +++ WSDDConstants.java	25 Aug 2002 14:00:02 -0000	1.21
  @@ -160,6 +160,7 @@
       public static final String ATTR_MODE = "mode";
       public static final String ATTR_STYLE = "style";
       public static final String ATTR_STREAMING = "streaming";
  +    public static final String ATTR_ATTACHMENT_FORMAT = "attachment";
       public static final String ATTR_PROVIDER = "provider";
       public static final String ATTR_PIVOT = "pivot";
       public static final String ATTR_SERIALIZER = "serializer";
  
  
  
  1.81      +13 -0     xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
  
  Index: WSDDService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- WSDDService.java	21 Aug 2002 03:36:33 -0000	1.80
  +++ WSDDService.java	25 Aug 2002 14:00:02 -0000	1.81
  @@ -61,6 +61,8 @@
   import org.apache.axis.Handler;
   import org.apache.axis.AxisFault;
   import org.apache.axis.MessageContext;
  +import org.apache.axis.attachments.Attachments;
  +import org.apache.axis.attachments.AttachmentsImpl;
   import org.apache.axis.description.ServiceDesc;
   import org.apache.axis.encoding.DeserializerFactory;
   import org.apache.axis.encoding.SerializationContext;
  @@ -124,6 +126,11 @@
       private boolean streaming = false;
   
       /**
  +     * What attachment format should be used?
  +     */
  +    private int sendType = Attachments.SEND_TYPE_NOTSET;
  +
  +    /**
        * Default constructor
        */
       public WSDDService()
  @@ -154,6 +161,11 @@
               streaming = true;
           }
   
  +        String attachmentStr = e.getAttribute(ATTR_ATTACHMENT_FORMAT);
  +        if (attachmentStr != null && !attachmentStr.equals("")) {
  +            sendType = AttachmentsImpl.getSendType(attachmentStr);
  +        }
  +
           Element [] operationElements = getChildElements(e, ELEM_WSDD_OPERATION);
           for (int i = 0; i < operationElements.length; i++) {
               WSDDOperation operation = new WSDDOperation(operationElements[i],
  @@ -386,6 +398,7 @@
                                                 respHandler);
           service.setStyle(style);
           service.setHighFidelityRecording(!streaming);
  +        service.setSendType(sendType);
   
           if ( getQName() != null )
               service.setName(getQName().getLocalPart());
  
  
  
  1.78      +18 -0     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.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- SOAPService.java	23 Aug 2002 15:08:55 -0000	1.77
  +++ SOAPService.java	25 Aug 2002 14:00:02 -0000	1.78
  @@ -65,6 +65,7 @@
   import org.apache.axis.description.ServiceDesc;
   import org.apache.axis.encoding.TypeMappingRegistry;
   import org.apache.axis.enum.Style;
  +import org.apache.axis.attachments.Attachments;
   import org.apache.axis.handlers.BasicHandler;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHeaderElement;
  @@ -110,6 +111,14 @@
       private boolean highFidelityRecording = true;
   
       /**
  +     * How does this service wish data which would normally be sent as
  +     * an attachment to be sent?  Default for requests is
  +     * org.apache.axis.attachments.Attachments.SEND_TYPE_DEFAULT,
  +     * and the default for responses is to match the request.
  +     */
  +    private int sendType = Attachments.SEND_TYPE_NOTSET;
  +
  +    /**
        * Our ServiceDescription.  Holds pretty much all the interesting
        * metadata about this service.
        */
  @@ -400,5 +409,14 @@
   
       public void setHighFidelityRecording(boolean highFidelityRecording) {
           this.highFidelityRecording = highFidelityRecording;
  +    }
  +
  +    // see org.apache.axis.attachments.Attachments
  +    public int getSendType() {
  +        return sendType;
  +    }
  +
  +    public void setSendType(int sendType) {
  +        this.sendType = sendType;
       }
   }
  
  
  

Mime
View raw message