Using the WebSphere Message Broker Mobile Service Pattern with WebSphere Cast Iron Web API Management

WebSphere Message Broker V8.0.0.1 provides a Mobile Service pattern to create an adapter for IBM Worklight from an existing service. This article shows you how to use the Mobile Service pattern to enable two consumer technologies and expose the services to Cast Iron.

Paul Smith (pasmith@uk.ibm.com), Solution Architect, WebSphere Connectivity and Integration team, IBM

Photo of Paul SmithPaul Smith is a Solution Architect on the WebSphere Connectivity and Integration team at the IBM Software Lab in Hursley Park, United Kingdom. You can contact Paul at pasmith@uk.ibm.com.



06 March 2013

Also available in Chinese

Introduction

The new Mobile Service pattern in IBM® WebSphere® Message Broker V8.0.0.1 enables you to create an IBM Worklight adapter from an existing service. At the core of this pattern is a method for converting SOAP/XML to REST/JSON and back, and this method also exposes the service to WebSphere Cast Iron Web API Management. This article shows you how to use the Mobile Service pattern to quickly and easily take existing Message Broker services and expose them via WebSphere Cast Iron Web API Management.

Creating a proxy for the service using WebSphere Message Broker

To start, assume that you have a SOAP service that gets a customer from a back-end system, and that you have downloaded the WSDL and XSD documents for this service. You first need to proxy this service using Message Broker:

  1. Open the Message Broker toolkit and clickNew Service:
  2. Name the service BCMGetCustomerServiceProxy, leave the option Create a new service interface selected, and then click Finish:
  3. Import the schemas for the service. Right-click on the project, select Import => General => Filesystem, and then click Next.
  4. Navigate to the directory where the documents are stored, select all of the schema documents, and click Finish:
  5. Import the WSDL documents: right-click on the project and select New => Message Model:
  6. Select SOAP XML and click Next:
  7. Select I already have WSDL for my data and click Next:
  8. In the Select file from outside workspace section, browse to your WSDL document and click Next:
  9. The binding will already be selected. Click Finish:

    You can now configure the interface for the new service proxy. The Interface Editor will already be open:
    1. Set the operation name to GetCustomer.
    2. Change the input object to inputCustomer with a type of APIGetCustomer.
    3. Change the output object to outputCustomer with a type of APICustomer.
  10. Save and close the Interface Editor:
  11. The workspace shows the artifacts that have been created. To create the service implementation, click GetCustomer:
  12. Drag a SOAPRequest node onto the flow and rename it GetCustomer.
  13. Drag the binding WSDL onto the SOAPRequest node to automatically configure the node:
  14. Drag a Mapping node onto the flow and double-click it to edit the map:
  15. Select the GetCustomer message as input and APIGetCustSimples as output, and then click Finish:
  16. Map the customerID from the input object to the output object. Save and close the map:
  17. Drag a SOAPExtract node onto the flow and place it after the SOAPRequest node:
  18. Drag another Mapping node onto the flow and double-click it to edit the map.
  19. Select the APIGetCustSimplesResponse message as input and GetCustomerResponse as output.
  20. Map all of the input fields to the output fields (the objects are largely identical). Save and close the map:
  21. The flow should look something like the picture below. Save the flow:
  22. Test the flow to ensure that it is working. Drag the service to an execution group to deploy it:
  23. Right-click on the service project and select Test:
  24. Add the customer ID to the input message and click Send Message:
  25. You should see a customer object returned from the service:

Using the Worklight Adapter Pattern to put a REST/JSON façade on the service implementation

  1. Open the Patterns Explorer and select Mobile Service:
  2. Click Create new instance:
  3. Give the pattern instance a name and click OK:
  4. Under Pattern Parameters, change Adapter description to a meaningful name.
  5. In the Service Information section, select the service that you just created:
  6. Once the pattern completes, you will see a new flow within your service project. Double-click on it to see what has been configured:
  7. Click on the HTTP Input node and then in the Properties. You will see the suffix required to call the service. The GetCustomer operation is used:
  8. Redeploy the service project to Message Broker.

Using WebSphere Cast Iron Web API Management.

  1. Before getting started, click Start Secure Connector to enable connections:
  2. Log into API Management and click Create to create a new API:
  3. Click on the newly created API to edit it:
  4. Add a POST operation to the API:
  5. Click on the Entitlements tab, create a basic entitlement with the number of calls that are allowed per minute, and then click Add:

    You will now see the basic entitlement.

  6. Return to the Resource Definition tab and click the BCMGetCustomer operation to edit it:
  7. On the Resource Details tab, add a sample JSON message for your service into the Request Body section:
  8. Add a sample JSON message for the response into the Response Body section:
  9. Click on the Implement Resource tab:
  10. Click the + symbol under Request and select a POST Operation:
  11. Give the connection a name and add the information required to connect to the service currently running on Message Broker.
  12. Select the secure connector that you want to use and click Connect:
  13. If everything is okay you should see a successful connection:
  14. Click Define and add the input and output JSON messages to the relevant sections:
  15. Click Configure and select the customerID from the input message:
  16. Click on the Response section to open the output configuration:
  17. Map all of the service response fields to the API output message, either by selecting the values individually… :
  18. …or using drag-and-drop mapping:
  19. After you have finished mapping, return to the main page for the new API and click Start to enable the resource:

    The resource should activate successfully:

  20. Switch to the Test tab, select the POST BCMGetCustomer resource, and then click Test Application. You should see the sample input message.
  21. Click Test:
  22. If the service is successful, you should see a response message coming back from the service:

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere, Mobile development
ArticleID=860754
ArticleTitle=Using the WebSphere Message Broker Mobile Service Pattern with WebSphere Cast Iron Web API Management
publish-date=03062013