org.ksoap2.serialization
Class SoapSerializationEnvelope

java.lang.Object
  extended by org.ksoap2.SoapEnvelope
      extended by org.ksoap2.serialization.SoapSerializationEnvelope

public class SoapSerializationEnvelope
extends SoapEnvelope

Author:
Stefan Haustein This class extends the SoapEnvelope with Soap Serialization functionality.

Field Summary
protected  boolean addAdornments
          Set to true to add and ID and ROOT label to the envelope.
protected  Hashtable classToQName
          Map from Java class names to XML name and namespace pairs
 boolean dotNet
          Set this variable to true for compatibility with what seems to be the default encoding for .Net-Services.
 boolean implicitTypes
          Set this variable to true if you don't want that type definitions for complex types/objects are automatically generated (with type "anyType") in the XML-Request, if you don't call the Method addMapping.
 Hashtable properties
           
protected static int QNAME_MARSHAL
           
protected static int QNAME_NAMESPACE
           
protected static int QNAME_TYPE
           
protected  Hashtable qNameToClass
          Map from XML qualified names to Java classes
 
Fields inherited from class org.ksoap2.SoapEnvelope
bodyIn, bodyOut, enc, ENC, ENC2001, encodingStyle, env, ENV, ENV2001, headerIn, headerOut, VER10, VER11, VER12, version, xsd, XSD, XSD1999, xsi, XSI, XSI1999
 
Constructor Summary
SoapSerializationEnvelope(int version)
           
 
Method Summary
 void addMapping(String namespace, String name, Class clazz)
          Defines a direct mapping from a namespace and name to a java class (and vice versa)
 void addMapping(String namespace, String name, Class clazz, Marshal marshal)
          Defines a direct mapping from a namespace and name to a java class (and vice versa), using the given marshal mechanism
 void addTemplate(SoapObject so)
          Adds a SoapObject to the class map.
 Object[] getInfo(Object type, Object instance)
          Returns a string array containing the namespace, name, id and Marshal object for the given java object.
 Object getResponse()
          Response from the soap call.
 Object getResult()
          Deprecated. Please use the getResponse going forward
 boolean isAddAdornments()
           
 void parseBody(org.xmlpull.v1.XmlPullParser parser)
           
 Object read(org.xmlpull.v1.XmlPullParser parser, Object owner, int index, String namespace, String name, PropertyInfo expected)
          Builds an object from the XML stream.
 Object readInstance(org.xmlpull.v1.XmlPullParser parser, String namespace, String name, PropertyInfo expected)
          Returns a new object read from the given parser.
protected  void readSerializable(org.xmlpull.v1.XmlPullParser parser, KvmSerializable obj)
          Read a KvmSerializable.
protected  void readSerializable(org.xmlpull.v1.XmlPullParser parser, SoapObject obj)
          Read a SoapObject.
protected  Object readUnknown(org.xmlpull.v1.XmlPullParser parser, String typeNamespace, String typeName)
          If the type of the object cannot be determined, and thus no Marshal class can handle the object, this method is called.
protected  void readVector(org.xmlpull.v1.XmlPullParser parser, Vector v, PropertyInfo elementType)
           
 void setAddAdornments(boolean addAdornments)
           
 void writeBody(org.xmlpull.v1.XmlSerializer writer)
          Serializes the request object to the given XmlSerliazer object
 void writeObjectBody(org.xmlpull.v1.XmlSerializer writer, KvmSerializable obj)
          Writes the body of an KvmSerializable object.
 void writeObjectBody(org.xmlpull.v1.XmlSerializer writer, SoapObject obj)
          Writes the body of an SoapObject.
protected  void writeProperty(org.xmlpull.v1.XmlSerializer writer, Object obj, PropertyInfo type)
           
protected  void writeVectorBody(org.xmlpull.v1.XmlSerializer writer, Vector vector, PropertyInfo elementType)
           
 
Methods inherited from class org.ksoap2.SoapEnvelope
parse, parseHeader, setOutputSoapObject, stringToBoolean, write, writeHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QNAME_TYPE

protected static final int QNAME_TYPE
See Also:
Constant Field Values

QNAME_NAMESPACE

protected static final int QNAME_NAMESPACE
See Also:
Constant Field Values

QNAME_MARSHAL

protected static final int QNAME_MARSHAL
See Also:
Constant Field Values

properties

public Hashtable properties

implicitTypes

public boolean implicitTypes
Set this variable to true if you don't want that type definitions for complex types/objects are automatically generated (with type "anyType") in the XML-Request, if you don't call the Method addMapping. This is needed by some Servers which have problems with these type-definitions.


dotNet

public boolean dotNet
Set this variable to true for compatibility with what seems to be the default encoding for .Net-Services. This feature is an extremely ugly hack. A much better option is to change the configuration of the .Net-Server to standard Soap Serialization!


qNameToClass

protected Hashtable qNameToClass
Map from XML qualified names to Java classes


classToQName

protected Hashtable classToQName
Map from Java class names to XML name and namespace pairs


addAdornments

protected boolean addAdornments
Set to true to add and ID and ROOT label to the envelope. Change to false for compatibility with WSDL.

Constructor Detail

SoapSerializationEnvelope

public SoapSerializationEnvelope(int version)
Method Detail

isAddAdornments

public boolean isAddAdornments()
Returns:
the addAdornments

setAddAdornments

public void setAddAdornments(boolean addAdornments)
Parameters:
addAdornments - the addAdornments to set

parseBody

public void parseBody(org.xmlpull.v1.XmlPullParser parser)
               throws IOException,
                      org.xmlpull.v1.XmlPullParserException
Overrides:
parseBody in class SoapEnvelope
Throws:
IOException
org.xmlpull.v1.XmlPullParserException

readSerializable

protected void readSerializable(org.xmlpull.v1.XmlPullParser parser,
                                SoapObject obj)
                         throws IOException,
                                org.xmlpull.v1.XmlPullParserException
Read a SoapObject. This extracts any attributes and then reads the object as a KvmSerializable.

Throws:
IOException
org.xmlpull.v1.XmlPullParserException

readSerializable

protected void readSerializable(org.xmlpull.v1.XmlPullParser parser,
                                KvmSerializable obj)
                         throws IOException,
                                org.xmlpull.v1.XmlPullParserException
Read a KvmSerializable.

Throws:
IOException
org.xmlpull.v1.XmlPullParserException

readUnknown

protected Object readUnknown(org.xmlpull.v1.XmlPullParser parser,
                             String typeNamespace,
                             String typeName)
                      throws IOException,
                             org.xmlpull.v1.XmlPullParserException
If the type of the object cannot be determined, and thus no Marshal class can handle the object, this method is called. It will build either a SoapPrimitive or a SoapObject

Parameters:
parser -
typeNamespace -
typeName -
Returns:
unknownObject wrapped as a SoapPrimitive or SoapObject
Throws:
IOException
org.xmlpull.v1.XmlPullParserException

readVector

protected void readVector(org.xmlpull.v1.XmlPullParser parser,
                          Vector v,
                          PropertyInfo elementType)
                   throws IOException,
                          org.xmlpull.v1.XmlPullParserException
Throws:
IOException
org.xmlpull.v1.XmlPullParserException

read

public Object read(org.xmlpull.v1.XmlPullParser parser,
                   Object owner,
                   int index,
                   String namespace,
                   String name,
                   PropertyInfo expected)
            throws IOException,
                   org.xmlpull.v1.XmlPullParserException
Builds an object from the XML stream. This method is public for usage in conjuction with Marshal subclasses. Precondition: On the start tag of the object or property, so href can be read.

Throws:
IOException
org.xmlpull.v1.XmlPullParserException

readInstance

public Object readInstance(org.xmlpull.v1.XmlPullParser parser,
                           String namespace,
                           String name,
                           PropertyInfo expected)
                    throws IOException,
                           org.xmlpull.v1.XmlPullParserException
Returns a new object read from the given parser. If no mapping is found, null is returned. This method is used by the SoapParser in order to convert the XML code to Java objects.

Throws:
IOException
org.xmlpull.v1.XmlPullParserException

getInfo

public Object[] getInfo(Object type,
                        Object instance)
Returns a string array containing the namespace, name, id and Marshal object for the given java object. This method is used by the SoapWriter in order to map Java objects to the corresponding SOAP section five XML code.


addMapping

public void addMapping(String namespace,
                       String name,
                       Class clazz,
                       Marshal marshal)
Defines a direct mapping from a namespace and name to a java class (and vice versa), using the given marshal mechanism


addMapping

public void addMapping(String namespace,
                       String name,
                       Class clazz)
Defines a direct mapping from a namespace and name to a java class (and vice versa)


addTemplate

public void addTemplate(SoapObject so)
Adds a SoapObject to the class map. During parsing, objects of the given type (namespace/name) will be mapped to corresponding copies of the given SoapObject, maintaining the structure of the template.


getResponse

public Object getResponse()
                   throws SoapFault
Response from the soap call. Pulls the object from the wrapper object and returns it.

Returns:
response from the soap call.
Throws:
SoapFault
Since:
2.0.3

getResult

public Object getResult()
Deprecated. Please use the getResponse going forward

See Also:
getResponse()

writeBody

public void writeBody(org.xmlpull.v1.XmlSerializer writer)
               throws IOException
Serializes the request object to the given XmlSerliazer object

Overrides:
writeBody in class SoapEnvelope
Parameters:
writer - XmlSerializer object to write the body into.
Throws:
IOException

writeObjectBody

public void writeObjectBody(org.xmlpull.v1.XmlSerializer writer,
                            SoapObject obj)
                     throws IOException
Writes the body of an SoapObject. This method write the attributes and then calls "writeObjectBody (writer, (KvmSerializable)obj);"

Throws:
IOException

writeObjectBody

public void writeObjectBody(org.xmlpull.v1.XmlSerializer writer,
                            KvmSerializable obj)
                     throws IOException
Writes the body of an KvmSerializable object. This method is public for access from Marshal subclasses.

Throws:
IOException

writeProperty

protected void writeProperty(org.xmlpull.v1.XmlSerializer writer,
                             Object obj,
                             PropertyInfo type)
                      throws IOException
Throws:
IOException

writeVectorBody

protected void writeVectorBody(org.xmlpull.v1.XmlSerializer writer,
                               Vector vector,
                               PropertyInfo elementType)
                        throws IOException
Throws:
IOException


Copyright © 2002-2011. All Rights Reserved.