示例#1
0
  /**
   * Get the content type of the attachments.
   *
   * @param sc provides the default content type
   * @return a <code>String</code> giving the content type of the attachment
   * @throws AxisFault if there was an error deducing the content type from this message
   */
  public String getContentType(SOAPConstants sc) throws AxisFault {
    boolean soap12 = false;

    if (sc != null) {
      if (sc == SOAPConstants.SOAP12_CONSTANTS) {
        soap12 = true;
      }
    } else {
      // Support of SOAP 1.2 HTTP binding
      SOAPEnvelope envelope = getSOAPEnvelope();
      if (envelope != null) {
        if (envelope.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
          soap12 = true;
        }
      }
    }

    String encoding = XMLUtils.getEncoding(this, msgContext);
    ;
    String ret = sc.getContentType() + "; charset=" + encoding.toLowerCase();

    // Support of SOAP 1.2 HTTP binding
    if (soap12) {
      ret = HTTPConstants.HEADER_ACCEPT_APPL_SOAP + "; charset=" + encoding;
    }

    if (getSendType() != Attachments.SEND_TYPE_NONE
        && mAttachments != null
        && 0 != mAttachments.getAttachmentCount()) {
      ret = mAttachments.getContentType();
    }
    return ret;
  }
示例#2
0
 /**
  * Writes this <CODE>SOAPMessage</CODE> object to the given output stream. The externalization
  * format is as defined by the SOAP 1.1 with Attachments specification.
  *
  * <p>If there are no attachments, just an XML stream is written out. For those messages that have
  * attachments, <CODE>writeTo</CODE> writes a MIME-encoded byte stream.
  *
  * @param os the <CODE>OutputStream</CODE> object to which this <CODE>SOAPMessage</CODE> object
  *     will be written
  * @throws SOAPException if there was a problem in externalizing this SOAP message
  * @throws IOException if an I/O error occurs
  */
 public void writeTo(java.io.OutputStream os) throws SOAPException, IOException {
   // Do it the old fashion way.
   if (getSendType() == Attachments.SEND_TYPE_NONE
       || mAttachments == null
       || 0 == mAttachments.getAttachmentCount()) {
     try {
       String charEncoding = XMLUtils.getEncoding(this, msgContext);
       ;
       mSOAPPart.setEncoding(charEncoding);
       mSOAPPart.writeTo(os);
     } catch (java.io.IOException e) {
       log.error(Messages.getMessage("javaIOException00"), e);
     }
   } else {
     try {
       mAttachments.writeContentToStream(os);
     } catch (java.lang.Exception e) {
       log.error(Messages.getMessage("exception00"), e);
     }
   }
 }