Apache SOAP API Reference

org.apache.soap.rpc
Class SOAPContext

java.lang.Object
  |
  +--org.apache.soap.rpc.SOAPContext

public class SOAPContext
extends java.lang.Object

SOAP context for a message. Encapsulates:

Author:
Wouter Cloetens (wcloeten@raleigh.ibm.com), Scott Nichol (snichol@computer.org)

Field Summary
protected  java.util.Hashtable bag
           
protected  java.lang.String currentId
           
protected  java.util.Hashtable deserializedMultiRef
           
protected  java.lang.ClassLoader loader
           
protected  java.util.Vector multiRef
           
protected  javax.mail.internet.MimeMultipart parts
           
protected  boolean rootPartSet
          This flag indicates if setRootPart() was called, so we can distinguish default root part resolution from deliberate root part indication.

 

Constructor Summary
SOAPContext()
          Constructor.

 

Method Summary
 void addBodyPart(javax.mail.internet.MimeBodyPart part)
          Adds a Part.
 void addBodyPart(javax.mail.internet.MimeBodyPart part, int index)
          Adds a MimeBodyPart at position index.
 void addDeserializedMultiRef(java.lang.String id, java.lang.Object o)
          Adds the multiRef deserialized for a particular id.
 int addMultiRef(java.lang.Object obj, Serializer ser)
          Adds a multiRef element.
 javax.mail.internet.MimeBodyPart findBodyPart(java.lang.String uri)
          Find the Mimepart referred to by the given URI.
 javax.mail.internet.MimeBodyPart findPartByLocation(java.lang.String uri)
          Find the Mimepart referred to by the given URI.
 java.lang.String getBaseURI()
          Determine the document's base URI, according to the following scheme: The Content-Location header of the root (SOAP) part.
 javax.mail.internet.MimeBodyPart getBodyPart(int index)
          Get the specified Part.
 javax.mail.internet.MimeBodyPart getBodyPart(java.lang.String CID)
          Get the Mimepart referred to by the given ContentID (CID).
 java.lang.ClassLoader getClassLoader()
           
 java.lang.String getContentType()
          Return the content-type
 int getCount()
          Return the number of enclosed BodyPart objects.
 java.lang.String getCurrentId()
          Gets the id attribute for the element currently being deserialized.
 java.lang.Object getDeserializedMultiRef(java.lang.String id)
          Gets the multiRef deserialized for a particular id.
 int getMultiRefCount()
          Gets the number of multiRefs.
 java.lang.Object getMultiRefObject(int id)
          Gets the multiRef object for a particular id.
 Serializer getMultiRefSerializer(int id)
          Gets the multiRef serializer for a particular id.
 java.lang.Object getProperty(java.lang.String name)
          Look for something in the hold-all 'bag'
 java.util.Enumeration getPropertyNames()
          Return the entire list of 'names' in the hold-all 'bag'
 javax.mail.internet.MimeBodyPart getRootPart()
          Find the root part.
 boolean isRootPartSet()
          Returns true is setRootPart() has been called.
 java.lang.Class loadClass(java.lang.String className)
           
 void readMultipart(javax.activation.DataSource ds)
          Initialise MIME multipart object from a data source.
 void removeBodyPart(javax.mail.internet.MimeBodyPart part)
          Remove a body part.
 java.lang.Object removeProperty(java.lang.String name)
          Remove something from the hold-all 'bag'
 void setClassLoader(java.lang.ClassLoader cl)
           
 void setCurrentId(java.lang.String id)
          Sets the id attribute for the element currently being deserialized.
 void setProperty(java.lang.String name, java.lang.Object value)
          Store something in the hold-all 'bag'
 void setRootPart(byte[] b, java.lang.String contentType)
          Set the root part to a provided string (usually the SOAP envelope).
 void setRootPart(javax.mail.internet.MimeBodyPart part)
          Adds the root BodyPart.
 void setRootPart(java.lang.String s, java.lang.String contentType)
          Set the root part to a provided string (usually the SOAP envelope).
 void setSubType(java.lang.String subtype)
          Set the MultiPart Mime subtype.
 java.lang.String toString()
          String representation for debug purposes.
 void writeTo(java.io.OutputStream os)
          Encode the root part or multipart and write to an OutputStream.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

parts

protected javax.mail.internet.MimeMultipart parts

bag

protected java.util.Hashtable bag

loader

protected java.lang.ClassLoader loader

multiRef

protected java.util.Vector multiRef

deserializedMultiRef

protected java.util.Hashtable deserializedMultiRef

currentId

protected java.lang.String currentId

rootPartSet

protected boolean rootPartSet
This flag indicates if setRootPart() was called, so we can distinguish default root part resolution from deliberate root part indication. Effect: calling setRootPart() twice will replace the original root part.
Constructor Detail

SOAPContext

public SOAPContext()
Constructor.
Method Detail

readMultipart

public void readMultipart(javax.activation.DataSource ds)
                   throws javax.mail.MessagingException
Initialise MIME multipart object from a data source.
Parameters:
ds - a DataSource object to read from
javax.mail.MessagingException

getBodyPart

public javax.mail.internet.MimeBodyPart getBodyPart(int index)
Get the specified Part. Parts are numbered starting at 0.
Parameters:
index - the index of the desired Part
Returns:
the Part, or null if no such part exists.

getBodyPart

public javax.mail.internet.MimeBodyPart getBodyPart(java.lang.String CID)
Get the Mimepart referred to by the given ContentID (CID). Returns null if the part is not found.
Parameters:
CID - the ContentID of the desired part
Returns:
the Part, or null if no such part exists.

findBodyPart

public javax.mail.internet.MimeBodyPart findBodyPart(java.lang.String uri)
Find the Mimepart referred to by the given URI. This can be: Returns null if the part is not found.

Note: relative URIs not entirely implemented yet.

Parameters:
uri - the URI
Returns:
the Part or null if not found

getBaseURI

public java.lang.String getBaseURI()
Determine the document's base URI, according to the following scheme:
  1. The Content-Location header of the root (SOAP) part.
  2. The Content-Location header of the multipart. (not implemented)
  3. "thismessage:/"

findPartByLocation

public javax.mail.internet.MimeBodyPart findPartByLocation(java.lang.String uri)
Find the Mimepart referred to by the given URI. This can be: Returns null if the part is not found.

Note: relative URIs not entirely implemented yet. We also can't pick up the base URI from the multipart (transport) headers yet, only from the root (SOAP) part.

Parameters:
uri - the URI
Returns:
the Part or null if not found

addBodyPart

public void addBodyPart(javax.mail.internet.MimeBodyPart part)
                 throws javax.mail.MessagingException
Adds a Part. The BodyPart is appended to the list of existing Parts.
Parameters:
part - The Part to be appended
Throws:
javax.mail.MessagingException
javax.mail.IllegalWriteException - if the underlying implementation does not support modification of existing values

addBodyPart

public void addBodyPart(javax.mail.internet.MimeBodyPart part,
                        int index)
                 throws javax.mail.MessagingException,
                        java.lang.IllegalArgumentException
Adds a MimeBodyPart at position index. If index is not the last one in the list, the subsequent parts are shifted up. If index is larger than the number of parts present, the MimeBodyPart is appended to the end.
Parameters:
part - The BodyPart to be inserted
index - Location where to insert the part
Throws:
javax.mail.MessagingException
javax.mail.IllegalWriteException - if the underlying implementation does not support modification of existing values
java.lang.IllegalArgumentException - if the part cannot be made into an attachment for some reason

removeBodyPart

public void removeBodyPart(javax.mail.internet.MimeBodyPart part)
                    throws javax.mail.MessagingException
Remove a body part.
javax.mail.MessagingException

setRootPart

public void setRootPart(javax.mail.internet.MimeBodyPart part)
                 throws javax.mail.MessagingException
Adds the root BodyPart. Add it in the first position, create a unique Content ID and set the "start" Content-Type header modifier that that.

Calling this method twice will replace the previous root part with the new one.

Parameters:
part - The BodyPart to be inserted
Throws:
javax.mail.MessagingException

setRootPart

public void setRootPart(java.lang.String s,
                        java.lang.String contentType)
                 throws javax.mail.MessagingException,
                        java.io.IOException
Set the root part to a provided string (usually the SOAP envelope). The string will be UTF-8 encoded.
Parameters:
s - The String to be inserted
contentType - the Content-Type of the root part
Throws:
javax.mail.MessagingException
java.io.IOException

setRootPart

public void setRootPart(byte[] b,
                        java.lang.String contentType)
                 throws javax.mail.MessagingException
Set the root part to a provided string (usually the SOAP envelope). The string will be UTF-8 encoded.
Parameters:
b - The String to be inserted
contentType - the Content-Type of the root part
Returns:
"start" Content-Type header modifier
Throws:
javax.mail.MessagingException

getRootPart

public javax.mail.internet.MimeBodyPart getRootPart()
                                             throws javax.mail.MessagingException
Find the root part. For multipart, search for a "start" Content-Type header modifier, if not present or invalid, assume the first part is the root.
Returns:
document root BodyPart
Throws:
javax.mail.MessagingException

setSubType

public void setSubType(java.lang.String subtype)
                throws javax.mail.MessagingException
Set the MultiPart Mime subtype. This method should be invoked only on a new MimeMultipart object created by the client. The default subtype of such a multipart object is "related".
Parameters:
subtype - Subtype
Throws:
javax.mail.MessagingException

isRootPartSet

public boolean isRootPartSet()
Returns true is setRootPart() has been called.

getCount

public int getCount()
             throws javax.mail.MessagingException
Return the number of enclosed BodyPart objects.
Returns:
number of parts
javax.mail.MessagingException

getContentType

public java.lang.String getContentType()
                                throws javax.mail.MessagingException
Return the content-type
Returns:
content type of the Mime multipart if there's more than one part, or of the root part if there's only one part
javax.mail.MessagingException

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException,
                    javax.mail.MessagingException
Encode the root part or multipart and write to an OutputStream.
Parameters:
os - stream to write to
Throws:
java.io.IOException
javax.mail.MessagingException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Store something in the hold-all 'bag'

getProperty

public java.lang.Object getProperty(java.lang.String name)
Look for something in the hold-all 'bag'

removeProperty

public java.lang.Object removeProperty(java.lang.String name)
Remove something from the hold-all 'bag'

getPropertyNames

public java.util.Enumeration getPropertyNames()
Return the entire list of 'names' in the hold-all 'bag'

setClassLoader

public void setClassLoader(java.lang.ClassLoader cl)

getClassLoader

public java.lang.ClassLoader getClassLoader()

loadClass

public java.lang.Class loadClass(java.lang.String className)
                          throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

getCurrentId

public java.lang.String getCurrentId()
Gets the id attribute for the element currently being deserialized. This will be null if there is no current id.
Returns:
The current id.

setCurrentId

public void setCurrentId(java.lang.String id)
Sets the id attribute for the element currently being deserialized. This will be null if there is no current id.
Parameters:
id - The current id.

addMultiRef

public int addMultiRef(java.lang.Object obj,
Serializer ser)
Adds a multiRef element. This may actually add the object, or it may simply return the id of the object as previously added. The id of the object is always between 0 and the count of multiRefs minus 1.
Parameters:
obj - The object for which a multiRef is desired.
ser - The serializer with which to serialize the object.
Returns:
The id of the element.

getMultiRefObject

public java.lang.Object getMultiRefObject(int id)
Gets the multiRef object for a particular id.
Parameters:
id - The id.
Returns:
The multiRef object for the id.

getMultiRefSerializer

public Serializer getMultiRefSerializer(int id)
Gets the multiRef serializer for a particular id.
Parameters:
id - The id.
Returns:
The multiRef serializer for the id.

getMultiRefCount

public int getMultiRefCount()
Gets the number of multiRefs. The multiRefs have id from 0 to count - 1.
Returns:
The number of multiRefs.

addDeserializedMultiRef

public void addDeserializedMultiRef(java.lang.String id,
                                    java.lang.Object o)
Adds the multiRef deserialized for a particular id.
Parameters:
id - The element id, as referred to by an href.
o - The deserialized object.

getDeserializedMultiRef

public java.lang.Object getDeserializedMultiRef(java.lang.String id)
Gets the multiRef deserialized for a particular id.
Parameters:
id - The id, as referred to by an href.
Returns:
The multiRef for the id.

toString

public java.lang.String toString()
String representation for debug purposes.
Overrides:
toString in class java.lang.Object

Apache SOAP API Reference

Copyright © 2001 Apache XML Project. All Rights Reserved.