Table of Contents

Search

  1. Preface
  2. Web Services
  3. SOAP Web Services
  4. WSDL Data Object
  5. Schema Object
  6. How to Create a SOAP Web Service
  7. Operation Mappings
  8. Parsing Web Service SOAP Messages
  9. Generating Web Service SOAP Messages
  10. Web Service Consumer Transformation
  11. REST Web Services
  12. How to Create a REST Web Service
  13. REST Web Service Consumer Transformation
  14. REST Web Service Consumer Transformation Use Cases
  15. REST and SOAP Web Service Administration
  16. Appendix A: Datatype Compatibility

Web Services Guide

Web Services Guide

How to Handle Request and Response Messages in XML Format

How to Handle Request and Response Messages in XML Format

You have an XML file that contains an element hierarchy that you want to use to create the request message that the REST Web Service Consumer transformation sends to a web service. The XML file includes data that you can use to identify a person at your organization such as their ID, name, e-mail, and country. These elements might appear in the XML file in the following way:
<Person><ID>sample</ID><Name>sample</Name><Email>sample</Email><Country>sample</Country></Person>
You have another XML file that contains an element hierarchy that you want to use to create the response message. The XML file includes data on the type of greeting that you want to use to address each person. The greeting includes data on the individual's ID and the greeting content. These elements might appear in the XML file in the following way:
<Greeting><ID>sample</ID><Content>sample</Content></Person>
To use the element hierarchy in these XML files in a REST Web Service Consumer transformation, first import the XML files as schema objects in the Developer tool, then use the schema objects to define the method input and the method output when you create the REST Web Service Consumer transformation.

Step 1. Create Schemas from the XML Files.

Complete the following steps to create a schema object for the method input. Repeat these steps to create a schema object for the method output.
  1. In the Developer tool, click
    File > New > Schema
    to open the schema wizard.
  2. Select
    Create from sample file
    .
  3. Click
    Browse
    .
  4. Navigate to the XML file and click
    Open
    .
  5. Enter a name for the schema and verify the project location. If required, browse to a new location.
    This dialog box shows the New schema wizard. The option Create from sample file is selected.
  6. Click
    Next
    to view the schema elements.
    This screenshot shows a preview of the schema object. You can see the parent element, Person, and the type, PersonType.
  7. Click Finish.
    You can use the schema object that you created to define the method input in the transformation.
  8. Repeat steps 1-7 to create a schema object for the method output.

Step 2. Create the REST Web Service Consumer Transformation.

Create the transformation. Use the schemas to define the method input and method output.
  1. In the Developer tool mapping editor, scroll down in the mapping palette to locate the REST Web Service Consumer transformation and drag it into the mapping.
  2. Enter a name for the transformation.
  3. Select an HTTP method. For this example, select the HTTP method Post.
    This screenshot shows the New REST Web Service Consumer Transformation wizard. You can specify Name, Location, and HTTP Method. For this example, the HTTP method Post is selected.
  4. Click
    Next
    to define the method input.
  5. Select
    Create from an element in a Schema Object
    .
    This image shows the dialog box to configure the method input for the REST Web Service Consumer Transformation. The option Create from an element in a Schema Object is selected.
  6. Click
    Browse
    .
  7. Select the parent element in the schema. In this example, the schema used for the method input contains the parent element
    Person
    .
    This image shows the dialog box that prompts you to select a schema element. It shows the schema object stored in the Model repository and the parent element in the schema object. The parent element for this schema object is Person.
  8. Click
    OK
    .
  9. Select
    Input mapping
    .
  10. Map the elements under
    RequestInput
    in the Ports area to
    Rest_Consumer_Input
    in the Method input definition area. Remember to map the key from the Ports area to the Method input definition area.
    This image shows the input mapping. The Ports area is on the left and the Method input definition is on the right. The elements in the Ports area are mapped to corresponding elements in the Method input definition area. The key nested under RequestInput is mapped to the key nested under Rest_Consumer_Input.
  11. To define the method output, click
    Next
    in the transformation wizard.
  12. Select
    Create from an element in a Schema Object
    .
  13. Select the parent element in the schema. In this example, the schema that we use for the method output contains the parent element
    greeting
    .
    This image shows the dialog box that prompts you to select a schema element. It shows the schema object stored in the Model repository and the parent element in the schema object. The parent element for this schema object is greeting.
  14. Map the elements under
    Rest_Consumer_Output
    in the Method output definition area to the Ports area. You are not required to map the key.
    This image shows a sample output mapping. The Method output definition area is on the left and the Ports area is on the right. The elements in the Method output definition area are mapped to corresponding elements in the Ports area. The key in the Method output definition area is not mapped to the Ports area.
  15. Click
    Finish
    .
    The following image shows how the transformation might appear in the mapping workflow:
    This image shows a mapping with a Read transformation, a REST Web Service Consumer transformation, and a Write transformation. The ports in the Read transformation are linked as input ports in the downstream REST Web Service Consumer transformation. The output port content in the REST Web Service Consumer transformation is linked to the downstream Write transformation.
  16. Select the REST Web Service Consumer transformation in the mapping editor.
  17. Navigate to the
    Properties
    view and select the
    Advanced
    tab.
  18. Configure the advanced properties. To enter a base URL, configure the property
    URL
    or enter an HTTP connection in the property
    Connection
    .
    This image shows the advanced properties for the REST Web Service Consumer transformation. The advanced properties include URL and Connection.

0 COMMENTS

We’d like to hear from you!