| Join wMUsers | Blog at wMUsers | User Control Panel | Site Map | webMethods Jobs |For Employers |
![]() | ![]() |
![]() |
IntroductionwebMethods Records provide interoperability between different systems, companies, and supply chains and offer a common, horizontal message architecture across an enterprise or business line.The webMethods Integration Server offers great flexibility in creating Records. A developer may choose to manually build a Record field-by-field, or alternatively, to automically build a Record based upon imported XML documents, DTDs, or Schemas. When mapping values between Records, a developer chooses one of three methods:
This article will focus on the third option -- performing mapping and transformations from within a Java service. Benefits to Mapping/Transforming in a Java ServiceWhen mapping Records within a Java service, a developer can get/set values from the pipeline and transform/map using Java. For a developer accustomed to Flow mapping or Built-in transformation services, understanding when to apply this approach may yield performance and manageability gains. Some reasons include:
The Values of IData ObjectsIn Flow, a webMethods Record may resemble Figure 1 below. The remainder of this webMethods Ezine article will reference this Record as we discuss how to manipulate its values from within a Java service. ![]() The root node of the Record is Order, as seen in Figure 1. Referencing the webMethods API, Order can be set to an IData object named orderList using the following Java code: IData orderList = (IData)ValuesEmulator.get(pipeline, "Order");
The IData object orderList contains several sub-nodes. To set the NewOrder node to an IData object, apply the following Java code:
IData newOrderList = (IData)ValuesEmulator.get(orderList, "NewOrder");
The same logic can be applied to set any sub-nodes with children as an IData object. IData bulkOrderList = (IData)ValuesEmulator.get(newOrderList, "BulkOrder");
An easier way to remember this is that (IData in Java service) = (Record in Flow service). Navigating an IData object in JavaThe values inside of an IData object can be easily retrieved, but first a developer must implement methods to access that data. Continuing the example above, orderInformationList is an IData object it is parent to the Record List OrderItems. To get and set elements within an IData object, it is necessary to create an IdataCursor object.
IDataCursor idc = orderInformationList.getCursor();
The getCursor() method retrieves an IdataCursor for the IData object orderInformationList. An IdataCursor object contains the most basic methods required to traverse an IData object and to get and set elements within it. After setting the cursor, it remains in its original, "unpositioned" state. That is, the cursor is not resting on an element of the IData object. To move the cursor to the first key/value pair whose key is equal to "OrganizationType", call the following static method:
idc.first("OrganizationType");
The cursor is now positioned on the key OrganizationType and its value can be retrieved using the method getValue().
String organizationType = (String)idc.getValue();
If OrganizationType is the only key to retrieve, be sure to explicitly discard the IdataCursor. Although the Java garbage collector will destroy the object eventually, its explicit destruction will provide more efficient performance. Use the following method to discard the IdataCursor:
idc.destroy();
Go Deeper on the Subject: The wMUsers Discussion Forums Carl Ozkaynak is a Senior Application Consultant with NerveWire Inc and has significant experience and expertise in multiple technologies. Carl specializes in system integration and has significant experience in Internet/Intranet, middleware, client/server, and distributed technologies. Carl has designed, delivered and lead Internet and Intranet projects for a variety of industries, including financial services, high-tech manufacturing, and telecommunications.
Carl can be reached via email at
|
| © All Rights Reserved, 2001-2008. |