Implementing the SOA OSS-J Inventory Web Service
This blog is for the developers of OSS TMF applications. It is for you the developers who understood all the specifications (well maybe…) and need to develop some real applications with real code ! This is a developer for developer blog. We will talk about the Java code, JAX-WS, XML , WSDL, JMS , the problems of using JAXB with polymorphism, the beauty of Spring and Hibernate and all the rest ! Please feel free to come up with questions , comments and critiques we will all learn from that.
We will start with a series of articles on the implementation of the Inventory Web Service. I will show you how to implement the Web Service stack on a simple information model. As we go I will also show you how the Inventory API is structured around a couple of OSS Design Patterns. Our first Inventory Web Service implementation will be EJB based and then we will migrate it to Spring.
You will need a basic knowledge of the OSS-J Inventory API, XMLSchema, WSDL and JAX-WS. You will also need
NetBeans, an XML Editor of your choice and
soapUI (a Web Services Testing tool). The
Inventory API specification is available from the TMF OSS-J site.
The first thing to know is that the OSS-J Inventory API is information model agnostic. What does that mean? It means that the API is not bound to a particular data model. It does mean that the API MUST be used in a polymorphic way. You have to supply a concrete information model and bind it to the hooks that exist in the API. Polymorphism means that the same basic entity may take multiple forms and the OO software can deal with that. From a Java perspective we use inheritance from a base class and from an XML Schema perspective we extend from a base type by using the complexContent construct. This way the operations relative to the base class can be performed on the extended entities.
Let's define a simple inventory data model. We will do that directly in XML Schema. Keep in mind we’re using a top down approach so we won’t start from Java we start from XML and WSDL. There are very good reasons why SOA architectures should always start from XML and WSDL but that’s anotherdiscussion. For this week blog will start by defining the XML schemas for two very simple data model entities (later on we will use a more sophisticated SID compliant IP-VPN model thanks to John Reilly!).
Our minimal data model will only contain two entity types. They are part of our resource model (no associations or specifications or events for this week!). We will name the two entities: Equipment and PhysicalTerminationPoint. Also we will need something to identify our entities. In OSS-J this identifier is named a key. Keep in mind that this is not a database key ! The Inventory API uses a polymorphic primary key to address the issue of having multiple vendor entity identification mechanisms. Our primary key is named InfoModelEntityPrimaryKey.
Let’s define our Entities and Key in XMLSchema
<schema xmlns:inv="http://osswave.com/xml/inv/v1-5" xmlns="http://www.w3.org/2001/XMLSchema"xmlns:cberes="http://ossj.org/xml/Common-CBEResource/v1-5"
xmlns:cbecore="http://ossj.org/xml/Common-CBECore/v1-5"
targetNamespace="http://osswave.com/xml/inv/v1-5" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<import namespace="http://ossj.org/xml/Common-CBEResource/v1-5"
schemaLocation="http://ossj.org/xml/Common-CBEResource/v1-5/OSSJ-Common-CBEResource-v1-5.xsd"/>
<complexType name="Equipment">
<complexContent>
<extension base="cberes:ResourceValue">
<sequence>
<element name="equipmentType" type="string" minOccurs="0"/>
<element name="numberOnHand" type="int" minOccurs="0"/>
<element name="location" type="string" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="PhysicalTerminationPoint">
<complexContent>
<extension base="cberes:ResourceValue">
<sequence>
<element name="userLabel" type="string" minOccurs="0"/>
<element name="additionalInformation" type="string" minOccurs="0"/>
<element name="location" type="string" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="InfoModelEntityPrimaryKey">
<sequence>
<element name="primaryKey" type="string" minOccurs="0"/>
</sequence>
</complexType>
<element name="equipment" type="inv:Equipment"/>
<element name="ptp" type="inv:PhysicalTerminationPoint"/>
<element name="entityPrimaryKey" type="inv:InfoModelEntityPrimaryKey"/>
</schema>
That’s it for this week ! Next week I will show you how to build the Inventory Web Service with NetBeans and use the Entities and Keys in Inventory SOAP requests and replies.
Posted
02-21-2010 12:15 PM
by
Pierre Gauthier