Thursday, July 21, 2011

MULE HTTP Web Service - Step3. Creating the transformation maps using Mule Data Integrator

This section focusses on creating the MDI transformation maps using the Mule Data Integrator Plugin in Eclipse. These maps will be used for transforming the incoming Soap request into Java Objects and the outgoing Java object into Soap response.

1. Switch to the data integrator perspective in Eclipse.
Window->Open Perspective->Other and select Data Integrator

2. Create a project named "ShippingServiceTransformers"
File->New->Project and in the wizard select Data Integrator Project and provide the name ShippingServiceTransformers

Data Integrator Project
3. Create the following folder structures to store the Maps and the structures.

Maps/request - This folder is used to keep the request object transformations. It would transform the incoming soap request to java object.

Maps/response - This folder is used to keep the response object transformations. It would transform the outgoing java object to soap response.

Structures/java - This is used to store the java structures generated using the client jar.

Structures/xsd - This is used to store the structures generated using the ShippingService.xsd schema.

Folder Structure

4. Import the XSD Schema.
  • Right click on Structures/xsd folder and click on Import.
  • Under Data Integrator, select XML Schema (XSD) and follow the steps as given below
Importing XSD Schema

Selecting the XSD

Select the classes that has to be generated

XSD Structure created successfully
5. Import the Java Structure.
  • Create a folder named class under the project root folder ShippingServiceTransformers.
  • Copy the class files from the client jar to the class folder. We will be using these class files to generate the Java Structure.
Classes Folder

Java Import

Select Folder where Java Structure needs to be created

Select the location where the classes are present
Import is completed Successfully

Java Structures Created


6. Create the Maps.
  • Maps are the ones that transforms the input structure to an output structure. Eclipse MDI Plug-in provides the most easiest way of just drag and drop feature to create the maps.
  • We will be creating four different maps as following
    • Request Maps
      • OrderShippingInfoRequestMap
      • GetShippingInfoRequestMap
    • Response Maps
      • OrderShippingInfoResponseMap
      • GetShippingInfoResponseMap
  • Right click on Maps/request folder and select New->Map
Standard Map
Provide a name for the Map
OrderShippingInfoRequestMap
  • Once the map is created, drag and drop the Structures/xsd/Elements/tns/GetShippingInfoRequest to INPUT(XML) in Map and Structures/java/com.services.shippingservice.GetShippingInfoRequest to Output (Java)
  • Once the structures are placed on the map, select the fields one by one on the input and drag and select the corresponding field on the output. This would map the fields and inform the transformers how the transformation has to be done.
In the same manner the other maps are also created.

OrderShippingInfoRequestMap
OrderShippingInfoResponseMap

OrderShippingInfoResponseMap
GetShippingInfoRequestMap

GetShippingInfoRequestMap
GetShippingInfoResponseMap

GetShippingInfoResponseMap


No comments:

Post a Comment