electric.soap
Class SOAPMessage

java.lang.Object
  extended byelectric.soap.SOAPMessage
All Implemented Interfaces:
IContextHolder, IMIMEConstants, ISOAPConstants

public final class SOAPMessage
extends java.lang.Object
implements ISOAPConstants, IMIMEConstants, IContextHolder

SOAPMessage represents a SOAPMessage, and includes methods for manipulating all of its aspects, including its XML document, XML envelope, XML body, XML fault, MIME attachments and MIME headers.

Author:
webMethods

Field Summary
 
Fields inherited from interface electric.soap.ISOAPConstants
ACTOR, ASYNC, BODY, DETAIL, ENCODING_STYLE, ENVELOPE, EXCEPTION, FAULT, FAULT_ACTOR, FAULT_CODE, FAULT_STRING, GET_SOAP_ACTOR, GET_SOAP_CODE, HEADER, MUST_UNDERSTAND, NEXT_ACTOR, OPTIMIZED_HEADER, SET_SOAP_ACTOR, SET_SOAP_CODE, SET_SOAP_DETAIL, SOAP_ACTION_HEADER, SOAP_BINDING, SOAP_ENCODING, SOAP_ENCODING_PREFIX, SOAP_ENVELOPE, SOAP_HTTP_TRANSPORT, SOAP_PREFIX, SOAP11_BINDING, SOAP11_ENCODING, SOAP11_ENVELOPE, SOAP12, SOAP12_BINDING, SOAP12_ENCODING, SOAP12_ENVELOPE, SOAP12_HTTP_CONTENT_TYPE, STACKTRACE, TME_PREFIX, UNDERSTOOD, XSD_PREFIX, XSI_PREFIX, XSI_SUFFIX
 
Fields inherited from interface electric.util.mime.IMIMEConstants
DATA_DIRECTORY, DEFAULT_MIMEDATA_DIRECTORY, DEFAULT_START_MIME_PART, MIME_ATTACHMENT_STYLE, MIME_EXTENSION, STAR_SLASH_STAR_DATAHANDLER
 
Constructor Summary
SOAPMessage()
          Construct a SOAP message with no associated XML document.
SOAPMessage(java.lang.Throwable exception)
          Construct a SOAP message for the given exception.
 
Method Summary
 void addAttachment(MIMEData attachment)
          Add the specified attachment.
 Element addBody()
          Add a body if one doesn't already exist, then return the body.
 Element addEnvelope()
          Add an envelope if one doesn't already exist, then return the envelope.
 Element addFault()
          Add a fault if one doesn't already exist, then return the fault.
 Element addHeader()
          Add a header if one doesn't already exist, then return the header.
 void addHeaderElement(Element element)
          Add the specified header element.
 void addMIMEHeader(java.lang.String name, java.lang.String value)
          Add a MIME header with the specified name and value.
 void deoptimize()
          If this message is optimized, undo the optimization by wrapping my payload in a standard SOAP body.
 MIMEData[] getAttachments()
          Return an array of all my attachments, or null if I have none.
 java.lang.String getAttachmentStyle()
           
 Element getBody()
          Return my body, or null if none exists.
 ByteArray getByteArray()
          Return a ByteArray version of my XML document.
 ByteArray getByteArray(WSDL wsdl)
           
 byte[] getBytes()
          Return a byte array version of my XML document.
 Context getContext()
           
 Document getDocument()
          Return my XML document.
 java.lang.String getEncodingStyle()
           
 Element getEnvelope()
          Return my envelope, or null if one doesn't exist.
 java.lang.String getEnvelopeNamespace()
          Return the envelope namespace.
 java.lang.Throwable getException()
          If I have a fault, return the exception that it represents, otherwise return null.
 Element getFault()
          Return my fault, or null if none exists.
 Element getHeader()
          Return my header, or null if none exists.
 Element getHeaderElement(java.lang.String name)
          Return the first header element with the specified name, or null if none exists.
 Element getHeaderElement(java.lang.String namespace, java.lang.String name)
          Return the first header element with the specified namespace an name, or null if none exists.
 Elements getHeaderElements()
          Return an enumeration of my header elements.
 Elements getHeaderElements(java.lang.String name)
          Return an enumeration of my header elements that have the specified name.
 Elements getHeaderElements(java.lang.String namespace, java.lang.String name)
          Return an enumeration of my header elements that have the specified namespace and name.
 Elements getHeaderElementsForSOAPActor(java.lang.String actor)
          Return an enumeration of my header elements which are aimed at an actor.
 java.lang.String getMIMEHeader(java.lang.String name)
          Return the first MIME header with the specified name.
 MIMEHeaders getMIMEHeaders()
          Return my MIME headers, or null if I have none.
 java.util.Enumeration getMIMEHeaders(java.lang.String name)
          Return an enumeration over the MIME headers with the specified name.
 SOAPOptimizations getOptimizations()
           
 Element getRoot()
          Return the root of my XML document, or null if I have no document.
 SOAPException getSOAPException()
          If I have a fault, return the exception that it represents as a SOAPException, otherwise return null.
 java.lang.String getSoapVersion()
          Return the namespace used for the soap:envelope as a proxy for the version of SOAP being used.
 boolean hasAttachment(java.lang.String contentID)
           
 boolean hasAttachments()
          Return true I have one or more attachments.
 boolean hasFault()
          Return true if I have a fault.
 boolean isException()
          Return true if I have a fault.
 void removeAttachment(MIMEData attachment)
          Remove the specified attachment.
 void removeAttachments()
          Remove all the attachments.
 Element removeBody()
          If I have a body, remove and return it, otherwise return null.
 Element removeEnvelope()
          If I have an envelope, remove and return it, otherwise return null.
 Element removeFault()
          If I have a fault, remove and return it, otherwise return null.
 Element removeHeader()
          If I have a header, remove and return it, otherwise return null.
 void removeHeaderElement(Element element)
          Remove the specified header element.
 void removeHeaderElement(java.lang.String name)
          Remove the first header element with the specified name.
 void removeHeaderElement(java.lang.String namespace, java.lang.String name)
          Remove the first header element with the specified namespace and name.
 void removeHeaderElements()
          Remove all the header elements.
 void removeHeaderElements(java.lang.String name)
          Remove the header elements with the specified name.
 void removeHeaderElements(java.lang.String namespace, java.lang.String name)
          Remove the header elements with the specified namespace and name.
 void removeMIMEHeader(java.lang.String name)
          Remove the first MIME header with the specified name.
 void removeMIMEHeaders()
          Remove all MIME headers.
 void removeMIMEHeaders(java.lang.String name)
          Remove all the MIME headers with the specified name.
 void setAttachments(MIMEData[] attachments)
          Set my attachments.
 void setAttachmentStyle(java.lang.String attachmentStyle)
           
 void setBody(Element body)
          Set my body.
 void setBytes(byte[] bytes)
          Set my XML document to a parsed version of the specified bytes.
 void setBytes(byte[] bytes, SOAPOptimizations optimizations, WSDL wsdl)
          Set my XML document to a parsed version of the specified bytes.
 void setContext(Context context)
           
 void setDocument(Document document)
          Set my XML document.
 void setDocument(Document document, SOAPOptimizations optimizations)
          Set my XML document.
 void setEnvelope(Element envelope)
          Set my envelope.
 void setException(java.lang.Throwable exception)
          Set my fault to represent the specified exception.
 void setFault(Element fault)
          Set my fault.
 void setHeader(Element header)
          Set my header.
 void setMIMEHeader(java.lang.String name, java.lang.String value)
          Add a MIME header with the specified name and value, replacing any existing MIME headers with the same name.
 void setSoapVersion(java.lang.String soapVersion)
          Set the SOAP version.
 int size()
           
 java.lang.String toString()
          Return an indented version of my XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SOAPMessage

public SOAPMessage()
Construct a SOAP message with no associated XML document.


SOAPMessage

public SOAPMessage(java.lang.Throwable exception)
Construct a SOAP message for the given exception.

Parameters:
exception -
Method Detail

toString

public java.lang.String toString()
Return an indented version of my XML document.


size

public int size()

getOptimizations

public SOAPOptimizations getOptimizations()

deoptimize

public void deoptimize()
If this message is optimized, undo the optimization by wrapping my payload in a standard SOAP body. GLUE calls this method on an optimized SOAP message before passing it to an interceptor.


getDocument

public Document getDocument()
Return my XML document.


getRoot

public Element getRoot()
Return the root of my XML document, or null if I have no document.


setDocument

public void setDocument(Document document)
Set my XML document.

Parameters:
document - A document that represents a SOAP message.

setDocument

public void setDocument(Document document,
                        SOAPOptimizations optimizations)
Set my XML document.

Parameters:
document - A document representing an optimized SOAP message.
optimizations -

getByteArray

public ByteArray getByteArray()
                       throws java.io.IOException
Return a ByteArray version of my XML document.

Throws:
java.io.IOException

getByteArray

public ByteArray getByteArray(WSDL wsdl)
                       throws java.io.IOException
Parameters:
wsdl -
Throws:
java.io.IOException

getBytes

public byte[] getBytes()
                throws java.io.IOException
Return a byte array version of my XML document.

Throws:
java.io.IOException

setBytes

public void setBytes(byte[] bytes)
              throws ParseException
Set my XML document to a parsed version of the specified bytes.

Parameters:
bytes - The bytes.
Throws:
ParseException - If an error occurs during the parsing process.

setBytes

public void setBytes(byte[] bytes,
                     SOAPOptimizations optimizations,
                     WSDL wsdl)
              throws ParseException,
                     java.io.UnsupportedEncodingException
Set my XML document to a parsed version of the specified bytes.

Parameters:
bytes - The bytes.
optimizations -
wsdl -
Throws:
ParseException - If an error occurs during the parsing process.
java.io.UnsupportedEncodingException

getEnvelope

public Element getEnvelope()
Return my envelope, or null if one doesn't exist.


setEnvelope

public void setEnvelope(Element envelope)
Set my envelope.

Parameters:
envelope - The new value.

removeEnvelope

public Element removeEnvelope()
If I have an envelope, remove and return it, otherwise return null.


addEnvelope

public Element addEnvelope()
Add an envelope if one doesn't already exist, then return the envelope.


getBody

public Element getBody()
Return my body, or null if none exists.


getEnvelopeNamespace

public java.lang.String getEnvelopeNamespace()
Return the envelope namespace. Note that the envelope namespace is used as a way to identify the exact soap version in use.

Returns:
the soap:envelope namespace.

setBody

public void setBody(Element body)
Set my body.

Parameters:
body - The new value.

removeBody

public Element removeBody()
If I have a body, remove and return it, otherwise return null.


addBody

public Element addBody()
Add a body if one doesn't already exist, then return the body. This method automatically creates an envelope if one doesn't already exist.


getFault

public Element getFault()
Return my fault, or null if none exists.


setFault

public void setFault(Element fault)
Set my fault.

Parameters:
fault - The new value.

removeFault

public Element removeFault()
If I have a fault, remove and return it, otherwise return null.


addFault

public Element addFault()
Add a fault if one doesn't already exist, then return the fault. This method automatically creates a body if one doesn't already exist.


hasFault

public boolean hasFault()
Return true if I have a fault.


getException

public java.lang.Throwable getException()
If I have a fault, return the exception that it represents, otherwise return null. todo: see notes on getSOAPException


getSOAPException

public SOAPException getSOAPException()
If I have a fault, return the exception that it represents as a SOAPException, otherwise return null. todo: deprecate, make clear this is a "best effort" to get an exception without having access to the wsdl


isException

public boolean isException()
Return true if I have a fault. todo: rename this to be "isFault"


setException

public void setException(java.lang.Throwable exception)
Set my fault to represent the specified exception.

Parameters:
exception - The exception. todo: deprecate and make clear this is "setGenericException"

getHeader

public Element getHeader()
Return my header, or null if none exists.


setHeader

public void setHeader(Element header)
Set my header.

Parameters:
header - The new value.

removeHeader

public Element removeHeader()
If I have a header, remove and return it, otherwise return null.


addHeader

public Element addHeader()
Add a header if one doesn't already exist, then return the header. This method automatically creates an envelope if one doesn't already exist.


getHeaderElement

public Element getHeaderElement(java.lang.String name)
Return the first header element with the specified name, or null if none exists.

Parameters:
name - The name.

getHeaderElement

public Element getHeaderElement(java.lang.String namespace,
                                java.lang.String name)
Return the first header element with the specified namespace an name, or null if none exists.

Parameters:
namespace - The namespace.
name - The name.

getHeaderElements

public Elements getHeaderElements()
Return an enumeration of my header elements.


getHeaderElementsForSOAPActor

public Elements getHeaderElementsForSOAPActor(java.lang.String actor)
Return an enumeration of my header elements which are aimed at an actor.

Parameters:
actor - The URI of the soap actor you're looking for

getHeaderElements

public Elements getHeaderElements(java.lang.String name)
Return an enumeration of my header elements that have the specified name.

Parameters:
name - The name.

getHeaderElements

public Elements getHeaderElements(java.lang.String namespace,
                                  java.lang.String name)
Return an enumeration of my header elements that have the specified namespace and name.

Parameters:
namespace - The namespace.
name - The name.

addHeaderElement

public void addHeaderElement(Element element)
Add the specified header element.

Parameters:
element - The element.

removeHeaderElement

public void removeHeaderElement(Element element)
Remove the specified header element.

Parameters:
element - The element.

removeHeaderElement

public void removeHeaderElement(java.lang.String name)
Remove the first header element with the specified name.

Parameters:
name - The name.

removeHeaderElement

public void removeHeaderElement(java.lang.String namespace,
                                java.lang.String name)
Remove the first header element with the specified namespace and name.

Parameters:
namespace - The namespace.
name - The name.

removeHeaderElements

public void removeHeaderElements(java.lang.String name)
Remove the header elements with the specified name.

Parameters:
name - The name.

removeHeaderElements

public void removeHeaderElements(java.lang.String namespace,
                                 java.lang.String name)
Remove the header elements with the specified namespace and name.

Parameters:
namespace - The namespace.
name - The name.

removeHeaderElements

public void removeHeaderElements()
Remove all the header elements.


getAttachments

public MIMEData[] getAttachments()
Return an array of all my attachments, or null if I have none.


setAttachments

public void setAttachments(MIMEData[] attachments)
Set my attachments.

Parameters:
attachments - The new value.

hasAttachments

public boolean hasAttachments()
Return true I have one or more attachments.


hasAttachment

public boolean hasAttachment(java.lang.String contentID)
Parameters:
contentID -

addAttachment

public void addAttachment(MIMEData attachment)
Add the specified attachment.

Parameters:
attachment - The attachment.

removeAttachment

public void removeAttachment(MIMEData attachment)
Remove the specified attachment.

Parameters:
attachment - The attachment.

removeAttachments

public void removeAttachments()
Remove all the attachments.


getAttachmentStyle

public java.lang.String getAttachmentStyle()
Returns:

setAttachmentStyle

public void setAttachmentStyle(java.lang.String attachmentStyle)
Parameters:
attachmentStyle -

addMIMEHeader

public void addMIMEHeader(java.lang.String name,
                          java.lang.String value)
Add a MIME header with the specified name and value.

Parameters:
name - The name.
value - The value.

setMIMEHeader

public void setMIMEHeader(java.lang.String name,
                          java.lang.String value)
Add a MIME header with the specified name and value, replacing any existing MIME headers with the same name.

Parameters:
name - The name.
value - The value.

getMIMEHeader

public java.lang.String getMIMEHeader(java.lang.String name)
Return the first MIME header with the specified name.

Parameters:
name - The name.

getMIMEHeaders

public java.util.Enumeration getMIMEHeaders(java.lang.String name)
Return an enumeration over the MIME headers with the specified name.

Parameters:
name - The name.

getMIMEHeaders

public MIMEHeaders getMIMEHeaders()
Return my MIME headers, or null if I have none.


removeMIMEHeader

public void removeMIMEHeader(java.lang.String name)
Remove the first MIME header with the specified name.

Parameters:
name - The name.

removeMIMEHeaders

public void removeMIMEHeaders(java.lang.String name)
Remove all the MIME headers with the specified name.

Parameters:
name - The name.

removeMIMEHeaders

public void removeMIMEHeaders()
Remove all MIME headers.


getEncodingStyle

public java.lang.String getEncodingStyle()

getSoapVersion

public java.lang.String getSoapVersion()
Return the namespace used for the soap:envelope as a proxy for the version of SOAP being used. As per the SOAP 1.2 spec: 2.8 SOAP Versioning Model

Returns:
SOAP_ENVELOPE or SOAP12_ENVELOPE

setSoapVersion

public void setSoapVersion(java.lang.String soapVersion)
Set the SOAP version. Must be an exact version that GLUE supports, represented symbolically by SOAP_ENVELOPE or SOAP12_ENVELOPE. Other settings will not work as expected.

Parameters:
soapVersion - SOAP_ENVELOPE or SOAP12_ENVELOPE.

getContext

public Context getContext()
Specified by:
getContext in interface IContextHolder
Returns:
message context.

setContext

public void setContext(Context context)
Specified by:
setContext in interface IContextHolder
Parameters:
context -


copyright© 2001-2004 by webMethods All Rights Reserved.