Creating a Web Service that Accesses Data from Two Data Objects Informatica
Abstract You can create a web service to provide web service clients access to data integration functionality. This article describes the steps to create a web service that provides web service clients access to data that is stored in a physical and a logical data object. Supported Versions Informatica Data Services 9.1.0 HotFix 4 Table of Contents Overview.... 2 Scenario.... 2 Prerequisites.... 3 Configuration Tasks.... 3 Step 1. Create a Web Service Object.... 3 Step 2. Configure the Customer Lookup Transformation.... 8 Step 3. Configure the Order Lookup Transformation.... 9 Step 4. Link Ports and Validate the Operation Mapping.... 9 Step 5. Test the Operation Mapping.... 10 Step 6. Deploy the Web Service to a Data Integration Service.... 10 Step 7. Provide Connectivity Information to the Web Service Client.... 11 Overview You can create a web service in the Developer tool to provide web service clients access to data integration functionality through a web service interface. A web service can have one or more operations. Each operation defines an action that the web service client can perform when the web service client connects to the web service. Web service operations include requests for information, requests to update data, or requests to perform tasks. For example, a web service client sends a SOAP request to run a web service operation called getcustomerorders. The web service client passes a customer ID in the request. The web service retrieves the customer and the order information. The web service returns the information to the web service client in a SOAP response. In the Developer tool, each operation corresponds to an operation mapping. The Data Integration Service processes the SOAP message based on how you configure the operation mapping. An operation mapping can consist of an Input transformation, an Output transformation, a Fault transformation, or other transformation types. You configure the Input transformation to parse SOAP messages. You configure the Output transformation and the Fault transformation to generate SOAP messages. Scenario Hypostores customer service representatives want to access customer data from the Los Angeles and Boston offices over a network. The customer service representatives want to view customer and order information based on the customer ID. A developer in the IT department has combined the data for the Los Angeles and Boston customer offices in a logical data object. Order information is available in a flat file. 2
The developer can create a web service that accepts a customer ID, looks up customer data in the logical data object, looks up order data in the flat file, and returns the customer and order details. Then, the developer can deploy an application containing the web service to a Data Integration Service. The administrator can provide the WSDL file to customer service so that customer service can connect to the web service. Prerequisites To implement the scenario, you must configure the operation mapping to look up data from a logical data object and a flat file data object. The steps in this scenario assume you created the following objects: Logical data object "Customers." To create the Customers logical data object, see "Tutorial Lesson 3: Creating a Logical View of Data" in the Data Services Getting Started Guide. Flat file physical data object "Orders." To create the Orders physical data object, import the orders.csv file from the tutorial files directory. For more information about creating logical and physical data objects, see the Data Services Getting Started Guide. Configuration Tasks To implement the scenario, you must create a web service object, configure the operation mapping, and deploy the web service to a Data Integration Service. After you deploy the web service, you can provide the web service connectivity information to customer service. 1. Create a web service object. 2. Configure a Lookup transformation to look up customer data. 3. Configure a Lookup transformation to look up order data. 4. Link ports and validate the operation mapping. 5. Test the operation mapping. 6. Deploy the web service object to the Data Integration Service. 7. Provide connectivity information to the web service client. Step 1. Create a Web Service Object Use the Developer tool to create a web service and create one or more web service operations. When you create an operation you can define the elements of the operation input, operation output, and operation faults. The Developer tool generates the contents of a WSDL file based on the web service properties and the operations that you define. You can preview the contents of a WSDL file after you create the web service. For this scenario, create one operation. Configure the operation input to receive a customer ID from a SOAP request. Configure the operation output to send a SOAP response that includes customer information and order information. 1. Open the project in which you want to create the web service. 2. Click File > New > Data Service. The New dialog box appears. 3
The following figure shows the New dialog box: 3. Select Web Service and click Next. The New Web Service dialog box appears. The following figure shows the New Web Service dialog box: 4. Enter the web service name. For this scenario, create a web service with the name WS_getCustomerByID. 5. Click Next. The Add Operations to Web Service page of the New Web Service dialog box appears. 6. Click the New button above the navigation pane. The wizard creates an empty operation input and an empty operation output. 7. Enter the operation name. The Developer tool uses the name you provide for the operation to define the names for the operation input and the operation output. For this scenario, create an operation with the name getcustomerbyid. 8. In the navigation pane, click getcustomerbyid_input to define the elements of the operation input. The operation input properties appear on the right side of the dialog box. 9. Define elements and child elements for operation input. SOAP requests for this operation can include the elements that you define for the operation input. To create an element, click the arrow next to the New button and select Element. Then, enter the element name. For this scenario, create an element with the name customerid. To change the element type, click the Type column of the element, click the Open button, and then browse to select the type. For this scenario, change the element type to integer. 4
The following figure shows the customerid element: 10. Click the Mapping Input tab to map data from the operation input to the output ports. By default, the Developer tool creates an output port for each element. The Developer tool also configures the node to port relationships. In this scenario, the Developer tool maps the customerid node to the customerid output port. Change the output port type to integer. The following figure shows the mapping between the customerid node and the customerid output port: 11. Click getcustomerbyid _Output to define the elements of the operation output. The operation output properties appear on the right side of the dialog box. 12. Define the elements and child elements for the operation output. To add a child element, select an element, click the arrow next to the New button and select Child Element. The SOAP responses include the elements that you define for the operation output. 5
For this scenario, enter the following elements and child elements: customerid (integer) customername (string) customerorders customerid (integer) orderid (integer) OrderContact (string) 13. Configure the minimum and the maximum number of occurrences for each element. Tip: When an element may occur more than one time in the SOAP response, configure a value greater than one for the Maximum Occurs column. In this scenario, a customer can have multiple orders. Therefore, set the maximum number of occurrences for the customerorders element to unbounded. The following figure shows the operation output elements: 14. Click the Mapping Output tab to map data from the input ports to the operation output. By default, the Developer tool creates an input port for each element. The Developer tool also configures the port to node relationships. In this scenario, the Developer tool configures the following port to node relationships: Port Name getcustomerbyidresponse getcustomerbyidresponse > customerid getcustomerbyidresponse > customername customerorders customerorders > customerid Operation Output Node Name Response > getcustomerbyidresponse Response > getcustomerbyidresponse > customerid Response > getcustomerbyidresponse > customername Response > getcustomerbyidresponse > customerorders Response > getcustomerbyidresponse > customerorders > customerid 6
Port Name customerorders > orderid customerorders > ordercontact Operation Output Node Name Response > getcustomerbyidresponse > customerorders > orderid Response > getcustomerbyidresponse > customerorders > ordercontact For the ID ports, change the input port type to integer. For the string ports, change the input port precision to 100. 15. Define the key relationships between elements. Because the order information can occur more than once in the operation output message, you need to use the customer ID as a key. In this scenario, the customerid relates the customer detail information to the customer order information. Therefore, customerid is a foreign key in the CustomerOrders node. To define the key relationships, configure the following additional port to node relationships: Port Name getcustomerbyidresponse > customerid customerorders > customerid Operation Output Node Name Response > getcustomerbyidresponse > Key_ getcustomerbyidresponse Response > getcustomerbyidresponse > customerorders > FKey_ getcustomerbyidresponse The following figure shows the mapping between the ports and the operation output nodes: 16. Click Finish. The Developer tool creates the web service object and an operation mapping for the operation. The operation mapping contains an Input transformation and an Output transformation. 7
Step 2. Configure the Customer Lookup Transformation Create and configure a Lookup transformation to look up data in a logical data object. For this scenario, create and configure a logical data object Lookup transformation to return the customer name for a particular customer ID. 1. In the Outline view, select the operation mapping. The Developer tool displays the operation mapping in the editor. 2. In the Object Explorer view, select a logical data object, and drag it to the editor. For this scenario, select and drag the Customer logical data object to the editor. Customer is a logical data object that combines the customer information from the LA and Boston offices. The Add to Mapping dialog box appears. 3. Select Lookup and click OK. Customer appears in the editor as a Lookup transformation. 4. Add a source port to the Lookup transformation. For this scenario, select the customerid column in the Input transformation and drag it to the Source Ports group in the Lookup_Customer transformation. The following figure shows the Lookup_Customer transformation with the linked source port: 5. In the editor, select the logical data object Lookup transformation. 6. To configure the lookup condition, select the Lookup tab in the Properties view and click the New (Insert) button. For this scenario, the following default lookup condition appears: CUSTOMER_ID = customerid. The following figure shows the lookup condition: 7. Click File > Save. 8
Step 3. Configure the Order Lookup Transformation Create and configure a Lookup transformation to look up order data. For this scenario, create and configure a logical data object Lookup transformation to return the customer name for a particular customer ID. 1. In the Object Explorer view, select a flat file data object, and drag it to the editor. For this scenario, select and drag the Orders flat file physical data object to the editor. Orders is a flat file physical data object that contains order information. The Add to Mapping dialog box appears. 2. Select Lookup and click OK. Orders appears in the editor as a Lookup transformation. 3. Add a source port to the Lookup transformation. For this scenario, select the customerid column in the Input transformation and drag it to the Source Ports group in the Lookup_Orders transformation. 4. In the editor, select the flat file physical data object Lookup transformation. 5. Select the General tab in the Properties view and set On multiple matches to Return all rows. For this scenario, set the property to return all rows, if there is more than one record that matches the lookup condition. 6. To configure the lookup condition, select the Lookup tab in the Properties view and click the New (Insert) button. For this scenario, configure the following lookup condition: Customer_ID=customerID. 7. Click File > Save. Step 4. Link Ports and Validate the Operation Mapping Link ports from the Lookup transformations to the Output transformation to define the flow of data. Then validate the mapping. 1. Link ports from the Lookup Columns groups of the Lookup transformations to the Input groups of the Output transformation. The following figure shows the operation mapping: 2. Right-click an empty area in the editor and click Validate. The Developer tool displays a message to indicate that it found no validation errors. 9
3. Click OK. 4. Click File > Save. Step 5. Test the Operation Mapping Test the operation mapping to verify that the operation mapping generates the expected SOAP response for a particular SOAP request. In the Data Viewer view, you can enter a SOAP request in the Input window and view the SOAP response in the Output window. For this scenario, test the operation mapping by providing a customer ID as input and previewing the customer details and the order details in the output. 1. Click an empty area in the editor. 2. Select thedata Viewer view. 3. In the Input window, replace the question mark (?) in the SOAP body with the data that the SOAP request contains. For this scenario, replace the question mark (?) with 10110095. 10110095 is a customer ID that appears in both the Customer logical data object and Order physical data object. 4. Click Run. The Output window displays the SOAP response based on the customer ID that you entered. The following figure shows the input and the SOAP response: Step 6. Deploy the Web Service to a Data Integration Service Deploy the web service to a Data Integration Service so that web service clients can connect to the web service. To deploy a web service, add the web service to an application and deploy the application to the Data Integration Service. 1. In the Object Explorer, select the web service object. 2. Right-click and select Deploy. The Deploy dialog box appears. 10
The following figure shows the Deploy dialog box: 3. Click Browse to select the domain which runs the Data Integration Service that runs the web service. 4. Select the Data Integration Service. 5. Click Next. 6. Enter the application name. 7. Click Finish. The Developer tool creates the application. Step 7. Provide Connectivity Information to the Web Service Client The WSDL contains the information that web service clients require to connect to a web service. Provide the web service clients the WSDL URL. When you access the WSDL URL, you can see the contents of the WSDL. 1. Login to the Administrator tool. 2. Select the Data Integration Service in the Navigator. 3. Select the Application view of the Data Integration Service. 4. Expand the application name in the top panel and select the web service. 5. Find the WSDL URL in the web service Properties view. For this scenario, send customer service the WSDL URL. Authors Padma Heid Lead Technical Writer Lori Troy Senior Technical Writer 11
Acknowledgements The authors would like to acknowledge Sumeet Kumar Agrawal, Thiagarajan Sundaramurthy, and Ellen Chandler for their technical assistance. 12