com.ibm.wsspi.webservices.binding
Interface CustomBinder


public interface CustomBinder

The custom binder is an interface to be implemented by the binding provider to deal with a particular pair of XML schema type and Java type. CustomBinder interface has two primary methods: serialize and deserialize; and both methods deal with a Java object and javax.xml.soap.SOAPElement. Once the binder is recognized by the engine runtime, it communicates with the runtime via the SOAPElement in the following ways: For serialization, the binder is invoked by the runtime and it receives a Java object and a SOAPElement. Java object is the data to be serialized, and SOAPElement is the context element for the serialization. Unlike the conventional serializer which writes out the raw data, the custom binder here is to produce an intermediate form of SOAP message: SOAPElement. The runtime takes care of writing the SOAPElement to the raw data. Obviously, it's easier to create the SOAPElement rather than the raw text since SAAJ APIs are available to help. Similarly for deserialization, the runtime builds an appropriate javax.xml.soap.SOAPElement instance and passes it to the binder which then deserializes it to a Java object.


Field Summary
static java.lang.String QNAME_SCOPE_COMPLEXTYPE
           
static java.lang.String QNAME_SCOPE_ELEMENT
           
static java.lang.String QNAME_SCOPE_SIMPLETYPE
           
 
Method Summary
 java.lang.Object deserialize(SOAPElement source, CustomBindingContext context)
          Deserialize the SOAPElement to the Java object.
 java.lang.String getJavaName()
          Return the class name of the java type to be handled by this CustomBinder
 javax.xml.namespace.QName getQName()
          Return the QName of the target XML schema type.
 java.lang.String getQNameScope()
          Return the qname scope of the target XML schema type.
 SOAPElement serialize(java.lang.Object bean, SOAPElement rootNode, CustomBindingContext context)
          Serialize the Java object to the SOAPElement
 

Field Detail

QNAME_SCOPE_ELEMENT

public static final java.lang.String QNAME_SCOPE_ELEMENT
See Also:
Constant Field Values

QNAME_SCOPE_COMPLEXTYPE

public static final java.lang.String QNAME_SCOPE_COMPLEXTYPE
See Also:
Constant Field Values

QNAME_SCOPE_SIMPLETYPE

public static final java.lang.String QNAME_SCOPE_SIMPLETYPE
See Also:
Constant Field Values
Method Detail

getQName

public javax.xml.namespace.QName getQName()
Return the QName of the target XML schema type.


getQNameScope

public java.lang.String getQNameScope()
Return the qname scope of the target XML schema type. Its value is either simpleType, complexType, or element.


getJavaName

public java.lang.String getJavaName()
Return the class name of the java type to be handled by this CustomBinder


serialize

public SOAPElement serialize(java.lang.Object bean,
                             SOAPElement rootNode,
                             CustomBindingContext context)
                      throws SOAPException
Serialize the Java object to the SOAPElement

Parameters:
bean - A Java object to be serialized by the custom binder. The type for this Java object has to be compatiable with what's returned by getJavaName(). If getJavaName() returns a name for a concrete class, the class for this "bean" object should be either the exact class or the derived class. If getJavaName() returna a name for a Java interface, the class for this "bean" has to implement this interface.
rootNode - A SOAPElement representing the root node upon which the custom binder operates. This SOAPElement is created by the runtime with the QName matching the QName of the "element" element defined in the schema and it does not have any child elements.
context - An object representing the binding context.
Returns:
a SOAPElement representing the serialized XML data.
Throws:
SOAPException - when a) the "bean" object does not match the advertised java class name b) the serialization fails.

deserialize

public java.lang.Object deserialize(SOAPElement source,
                                    CustomBindingContext context)
                             throws SOAPException
Deserialize the SOAPElement to the Java object.

Parameters:
source - a SOAPElement representing the XML message from the wire. It has all necessary namespace declarations, including those inherited from the parent element.
context - An object representing the binding context.
Returns:
a Java object which is deserialized from the source SOAPElement. Its type has to be compatible with what's returned by getJavaName() method.
Throws:
SOAPException - when it fails to deserialize the passed SOAPElement to appropriate object.