IBM WebSphere Application Server V7.0 Feature Pack for Service Component Architecture V1.0.1
IBM WebSphere Application Server V7.0 Feature Pack for Service Component Architecture V1.0.1 Data binding - SDO
This presentation covers SDO data binding in the WebSphere® Application Server Feature Pack for Service Component Architecture.
Key features of SDO data binding
Serialization/deserialization of data between the application and wire Scope Management Basic Shared scopes Programming model API to access default scope JAX-WS Based Key features of SDO data binding
The SDO data binding support includes serialization and deserialization of data between the application and the wire; scope management, which is either basic or shared; and the JAX-WS based programming model. Each of these features is covered in detail in the next couple of slides.
Serialization/deserialization of data
Used to marshall/unmarshall service interface input/output/fault values to/from the application service client/implementation SDO defines a mapping between XML document and an instance of SDO’s commonj.sdo.DataObject XML document = wire data format DataObject = application data format Serialization/deserialization of data
An important aspect of SDO is that it is used to marshall and unmarshall service interface input, output, and fault values to and from the application service client or service implementation. In a manner parallel to JAXB, SDO defines a mapping between an XML document and an instance of SDO’s commonj.sdo.DataObject. An XML document is used for the wire data format, and a DataObject is the application data format. This happens in the scope of the application’s default HelperContext.
Example – XML document, XSD, SDO Java™
Example – XML document, XSD, SDO Java™ JohnDoeGO public void myOperation(DataObject person, String code) { String first = person.getString(“firstName”); // John String last = person.getString(“lastName”); // Doe SCA JAVA Service Impl XML payload on wire XSD in original (doc-lit-wrapped) WSDL Payload conforms to Deserializes to: (note unwrapping of doc-lit-wrapped wrapper) Data model described by
Here is an example of an XML document, XSD, and SDO Java.
Scope management
In SDO, a scope = an instance of commonj.sdo.helper.HelperContext SCA defines SDO scopes within boundaries meaningful from SCA-application perspective SCA/SDO runtimes together provides SCA applications with a default HelperContext Scope management
In SDO, a scope corresponds precisely to an instance of commonj.sdo.helper.HelperContext. As with any scope, this defines visibility boundaries for SDO types. In the Feature Pack for SCA, the SCA layer defines HelperContext on SCA application boundaries, which are meaningful boundaries from an SCA perspective. Together, SCA and SDO define a default HelperContext for a given application and enable the SCA application to access this programmatically.
Scope mgmt – based on deployable composite and contribution
SCA creates a unique HelperContext (scope) for each deployable composite Each deployable composite is contributed to the SCA domain by a single contribution (JAR) All schema definitions in WSDL/XSD files packaged within the same contribution JAR is added (on-demand) to a given deployable composite’s HelperContext No programmatic API calls like the SDO XSDHelper.define() API Scope mgmt – based on deployable composite and contribution
The service component architecture creates a unique HelperContext, or scope, for each deployable composite. Each deployable composite is contributed to the SCA domain by a single JAR. All schema definitions in WSDL/XSD files packaged within the same contribution JAR are added, on-demand, to a given deployable composite’s HelperContext. This happens without any programmatic API calls.
Scope mgmt - registration of schema definitions
SCA registers schema definitions from your SCA application’s WSDL/XSDs to your application HelperContext Registered definitions is used by: The runtime, to establish the SDO Type of DataObject instantiated by deserializing service request/response data from the wire The application, to create DataObject of application-specific Type Scope mgmt - registration of schema definitions
The SCA run time provides mechanisms to register schema definitions from your SCA application (for example, in WSDL/XSD files packaged with your application) to your SCA-meaningful scopes, such as your application default HelperContext. Schema registration is important because when using SDO to interact with XML data, the exact details of your application's SDO programming model can be affected. They can be affected by whether the relevant SDO scope recognizes the schema definitions in the original XML document (such as the wire format data coming in over the binding invocation). For example, the commonj.sdo.DataObject method Object get(int propertyIndex) might return a single DataObject in cases where get() is invoked on an object corresponding to a registered schema element or type. It might return a list in cases where the schema definitions corresponding to the payload are unrecognized.
Scope mgmt – shared scopes
Multiple components/composites can load schema definitions into a shared SDO scope reduces memory footprint Uses SCA contribution import and export Integrated with pass-by-reference optimization Shared scopes also work within a business level application (BLA) Scope mgmt – shared scopes
Multiple components or composites can load commonly-used schema definitions into a shared SDO scope. This reduces memory footprint. Shared scopes also use SCA Contribution import/export. You can package a set of shared schemas into a single contribution, export certain XML namespaces, and import those namespaces from your composites’ contributions. Another aspect of shared scopes is that it is also integrated with pass-by-reference optimization. It also works within a business level application. For each shared contribution exporting schema definitions (XSD), any two composites in the same business level application that import those definitions will load from a single SDO scope.
Shared scopes diagram
Shared scopes diagram sca-contribution.xml InsuranceSchemaPackContrib.jar InsuranceClaim.jar MyInsuranceBLA ClaimComposite PaymentComposite sca-contribution.xml sca-contribution.xml InsurancePayment.jar
Here is an example of shared scopes. Note how ClaimComposite and PaymentComposite from MyInsuranceBLA load from a single SDO
API to access default scope
API to access default scope @com.ibm.websphere.soa.sca.sdo.DefaultHelperContext The runtime will inject a public or protected field/setter with the application-specific HelperContext import com.ibm.websphere.soa.sca.sdo.DefaultHelperContext; … @DefaultHelperContext protected HelperContext defaultHC; …. DataFactory dataFactory = defaultHC.getDataFactory(); DataObject person = dataFactory.create("http://test", "Person");
As you saw in some earlier slides, SCA and SDO define a default HelperContext for a given application and enable the SCA application to access this programmatically. The default HelperContextFactory is accessible through the interface commonj.sdo.helper.SDO. The runtime will inject a public or protected field or setter with the application-specific HelperContext. In the example shown, the XSD type with QName {http://test}Person is defined in an XSD file packaged in the same contribution as the deployable composite using this Java code in a component. The annotation gives you access to this scope.
JAX-WS based programming model
JAX-WS based programming model JAX-WS defines interface-level mapping, between WSDL portType operation and Java interface method JAX-WS annotations significant in SCA applications using SDO @RequestWrapper, @ResponseWrapper, @WebParam, @WebResult For individual input parameter and return types, SDO defines mapping between XSD and Java, rather than JAXB Exception/fault handling defined by JAX-WS Mapping between the “fault bean” and schema defined by SDO, rather than JAXB
SCA feature pack uses JAX-WS to define the operation-level mappings between WSDL/XSD and the Java interface method, and uses SDO to define the mapping between XSD types and the corresponding Java parameter types. Thus, there is a single SCA programming model based on JAX-WS, with the ability to "plug in" either the JAXB data binding or SDO data binding. One consequence of this is that the JAX-WS annotations like those shown here are significant in SCA applications using SDO. Another important consequence is that the product uses JAX-WS to define the mapping between a Java exception thrown or caught in Java clients and implementations, and the "fault bean" that is serialized "on the wire”. The "fault bean" can be an SDO of type commonj.sdo.DataObject, in which case the SDO XMLHelper is used to serialize or deserialize the fault bean to or from the wire format.
SDO known versus. unknown type
SDO known versus. unknown type The (XSD/SDO) type of the DataObject can either be known or unknown “unknown” type scenario is treated as the SDO-equivalent of xsd:anyType can affect the programming model used to interact with DataObject’s properties In SCA, top-down approach used to program with “known” types, bottom-up approach results in “unknown” types
When working with a DataObject in your SCA client or SCA implementation, the (XSD/SDO) type of the object can either be known or unknown. The “unknown” type scenario is treated as the SDO-equivalent of xsd:anyType. This can affect the programming model used to interact with your DataObject’s properties. In SCA, top-down approach (starting from WSDL), can be used to program with “known” types, whereas bottom-up approach (starting from Java) typically results in “unknown” types.
Example: Schema definition unknown
DataObject personDO = ...; // corresponds to 'Person' XSD type List