| XML and related standards for data warehouses | Table of contents | Indexes | How XML Enables Internet Trading Communities and Marketplaces | |||
Fairfax ![]() Gauthier, Jay USA ![]() webMethods, Inc. | Jay Gauthier |
| Senior Software Engineer |
| webMethods, Inc. |
| 3877 Fairfax Ridge Road, 4th Floor
Fairfax
(Virginia)
USA
(22030)
Email: mailto:Jgauthier@webmethods.com |
| Biography |
Introduction |
| A simplified example might be a Flow service called 'handleCustomerRequest: |
Definitions |
Flow Operations |
| Flow operations are combined to create a Flow service, one that processes an incoming purchase order, for example. Operations can be nested to form arbitrarily complex services. |
|
Flow Example |
| In the example from the introduction, the Flow service 'handleCustomerRequest' would have been defined as having a single input field, say 'CustomerRequest', corresponding to the root element of a parsed XML document. When the service is invoked, the pipeline initially contains at least this one field. |
| This 'CustomerRequest' is a Record with embedded fields for, among other things, the CustomerID, RequestType, and the list of items. These fields may be deeply nested within the record, and there can be numerous other fields that are to be ignored within this service. |
| The XML might look like this: |
<CustomerRequest> |
<Header> |
<CustomerInfo> |
<CustomerID>22920</CustomerID> |
<Address>...</Address> |
</CustomerInfo> |
<RequestType>PriceCheck</RequestType> |
</Header> |
<Item> |
<Product>Grapple Grommets</Product> |
<Quantity>1000</Quantity> |
</Item> |
<Item> |
<Product>Doohickey</Product> |
<Quantity>500</Quantity> |
</Item> |
</CustomerRequest> |
| A document like this could be represented by the following nested fields: |
CustomerRequest (Record) |
Header (Record) |
CustomerInfo (Record) |
CustomerID (String) |
Address (Record) |
RequestType (String) |
Item (RecordList) |
Product (String) |
Quantity (String) |
| The first operation in handleCustomerRequest is to INVOKE a built-in service called "documentToRecord" which translates the incoming XML document into a CustomerRequest record detailed above. |
| Next, a MAP operation will pull out the CustomerID, RequestType and Item list fields from the CustomerRequest record and insert them into the pipeline as top-level fields. The data is not copied - only a new reference (or pointer) to it is inserted into the pipeline. This prepares the pipeline for subsequent INVOKE operations. |
| INVOKE validateCustomerID is the next operation in the example. In a business application, this might confirm that the CustomerID truly is a client by looking it up in a database. There is no error checking illustrated above, but the validateCustomerID service could be defined to fail with an appropriate message if the CustomerID is unknown. |
| Since this one XML document type can be used for two types of requests: price checks and actual orders, a BRANCH operation is used to check the value of the RequestType field. BRANCH is a container whose sub-operations are labeled to match the value of the field being inspected. In the example above, RequestType is 'PriceCheck', so the first sub-operation will be executed next. |
| In this very simple example, each item is described by a Product and Quantity. The INVOKE documentToRecord at the beginning will turn a series of "Item" XML elements into a list of "Item" records (a Record array in Java). To handle a PriceCheck request, this example will LOOP over each "Item" and perform a sequence of operations. |
| The first step in handling a PriceCheck for an item is to validate the value of the Product field. Again, in a business application this would check a database or other enterprise application. |
| If valid, another service "checkInventory" is called to verify the availability of the Product and Quantity specified. |
| Lastly, the service getPriceForCustomer returns the price per unit of that product in that quantity for that customer. |
| XML and related standards for data warehouses | Table of contents | Indexes | How XML Enables Internet Trading Communities and Marketplaces | |||