Creating a SOAP API with IBM API Management 4.0.0.0

Transcription

Creating a SOAP API with IBM API Management 4.0.0.0
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Creating a SOAP API with
IBM API Management 4.0.0.0
© 2015 Copyright IBM Corporation
Page 1 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
TABLE OF CONTENTS
OBJECTIVE....................................................................................................................................3
PREREQUISITES...........................................................................................................................3
CASE STUDY.................................................................................................................................4
USER ROLES.................................................................................................................................4
BEFORE YOU BEGIN....................................................................................................................5
LOG INTO THE API MANAGER....................................................................................................7
CREATE AN ACCOUNTSERVICE SOAP API.............................................................................. 8
ADD THE GETBALANCE RESOURCE TO THE SANDBOX PLAN ..........................................15
SET A RATE LIMIT FOR THE GETBALANCE RESOURCE......................................................18
TEST THE GETBALANCE RESOURCE.....................................................................................20
SUMMARY....................................................................................................................................24
© 2015 Copyright IBM Corporation
Page 2 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Objective
In this tutorial, you will learn:
 How to create a SOAP API definition
 How to set a rate limit for a Resource on a Plan
 How to test that a rate limit is being enforced for a resource
Prerequisites
This tutorial is the third in a series, it builds on the Creating a proxy REST API with IBM API
Management 4.0.0.0 and Creating an assembly REST API with IBM API Management
4.0.0.0 tutorials.
For more information about this series and other tutorials please see:
http://developer.ibm.com/apimanagement
© 2015 Copyright IBM Corporation
Page 3 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Case study
Bank A has an existing set of SOAP based services that they would like to expose through APIs
in order to foster growth within the mobile and device market. The Bank A business team
understands that an increased mobile and device application presence will enhance their brand
image and increase customer satisfaction.
They considered building their own API management solution, the Bank A technology team has
decided to implement an IBM API Management solution because it will allow them to enter the
market quickly at a reduced cost.
In this tutorial you will develop the Bank A API Management solution. The initial solution will
include the documentation and definition of a pure proxy to access the balance enquiry SOAP
service as shown in Figure 1 below. This simple proxy allows Bank A to monitor the use of the
service and restrict access to the API. In this case, the SOAP service will be configured from a
Web Service Definition Language (WSDL) document.
Figure 1 – Balance Enquiry SOAP API.
User roles
IBM API Management 4 allows different roles to be assigned to users. For more details about
the different user roles please see the following page in the product documentation:
Adding users and assigning roles
This tutorial has been written assuming that you are an Administrator or Organization Owner.
© 2015 Copyright IBM Corporation
Page 4 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Before you begin
Access the Bank A Backend Service
Before you setup an API in the IBM API Management product, you need to verify that the
backend account service is working and accessible. Remember that the goal is to expose this
service as a managed API on the IBM API Management platform.
1. Open a new browser tab and navigate to the URL
http://banka.mybluemix.net/home/index.html
2. Click on the Endpoint for the service titled Account Service (SOAP) to make sure that the
account service is operational. This is the service that you would like to expose via the API
gateway.
© 2015 Copyright IBM Corporation
Page 5 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
3. By clicking on the link you are making a REST based GET call to the account service, which
will return a basic message identifying it as a Web service. Validate that the account service
responds.
4. Click the browser back button, and click the WSDL link for the Service titled Account
Service (SOAP) to ensure the WSDL URL is working correctly.
5. Validate that the account service WSDL is displayed.
© 2015 Copyright IBM Corporation
Page 6 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Log into the API Manager
6. Open a new browser tab and navigate to the URL
https://<managementserver>/apimanager
Where <managementserver> is the IP Address or hostname of your management server.
7. Sign in to the IBM API Management platform by entering your credentials and clicking Sign
In.
8. Confirm that you are logged into the correct organization.
9. After you sign in, the API Manager Home page is displayed. The home screen displays
activity graphs for each environment.
© 2015 Copyright IBM Corporation
Page 7 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Create an AccountService SOAP API
Now that you have a logged into the API Manager, you can start creating a SOAP API to expose
and manage Bank A’s account service.
10. Select APIs from the navigation pane.
11. Click the + API button and select Import WSDL to create a new SOAP API.
© 2015 Copyright IBM Corporation
Page 8 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
12. Populate the fields as shown in the table below. The WSDL URL can be copied and pasted
from the other browser tab where you viewed the WSDL.
When complete, click the Load button.
Field Name
Value
WSDL URL
http://banka.mybluemix.net/services/AccountService?wsdl
Username
<Leave blank>
Password
<Leave blank>
© 2015 Copyright IBM Corporation
Page 9 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
13. The API Manager has loaded the WSDL document from the URL provided and parsed it to
list the services available. Select AccountService and click Add. Optionally click Show
Operations to view the operations in the service as displayed below.
© 2015 Copyright IBM Corporation
Page 10 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
14. After creating the AccountService API it will immediately appear in the list of draft APIs.
Click on the AccountService API link to view the details.
15. Review the AccountService SOAP API Security configuration. Click on Security.
© 2015 Copyright IBM Corporation
Page 11 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
16. The API identification and authentication requirements are displayed beneath the titles
"Identify Application Using" and "Authenticate Application Users Using".
Check that Identify Application Using is set to Client ID.
17. Review the AccountService SOAP APIs resource configuration. Go to the Resources tab.
18. Confirm that the getBalance resource is listed for the AccountService. From here you can
edit the resource.
© 2015 Copyright IBM Corporation
Page 12 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
19. In the overview tab you can view a sample SOAP request and response bodies and faults for
the resource. In this case there are no faults defined for the service, so that section is
empty.
20. Review the AccountService SOAP APIs Provider Endpoint configuration. Click the
Implementation tab and select Proxy.
© 2015 Copyright IBM Corporation
Page 13 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
21. Note that the provider endpoint has been parsed from the wsdl and can be seen in the Proxy
URL field. This can be overidden at this point by editing the URL. However, there is no need
to do this for this tutorial so there is no action required.
22. Click Save at the top right corner to save your API.
© 2015 Copyright IBM Corporation
Page 14 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Add the getBalance Resource to the Sandbox Plan
In order to be able to test the resource from the integrated test tool you need to first add it to a
plan. In a previous tutorial you created a plan, named Sandbox. It is this plan that you will use to
test the Branch Location resource.
23. Select Plans from the navigation pane.
24. Click on the Sandbox Plan name to open the plan editor.
© 2015 Copyright IBM Corporation
Page 15 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
25. Click + Resource.
26. In the Add Resources dialog box. Select AccountService from the list of APIs in the left
hand column, then select the getBalance resource. Click Add.
© 2015 Copyright IBM Corporation
Page 16 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
27. The getBalance resource is now part of the Sandbox plan.
© 2015 Copyright IBM Corporation
Page 17 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Set a Rate Limit for the getBalance Resource
28. From the plan editor you can set rate limits for either the plan as a whole or for resources
individually. For the purpose of this tutorial you are going to set a rate limit for the getBalance
resource that you have just added to the Public plan.
Click the Rate Limit Edit icon for the getBalance resource.
29. Set a restrictive rate limit on the resource of 1 request per minute. Populate the fields in the
Rate limit dialog as described in the table below then click Apply:
Field Name
Value
Number of Requests
1
Time Interval
1 Minutes
30. The rate limit is now displayed for this resource in the plan editor.
© 2015 Copyright IBM Corporation
Page 18 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
31. The rate limit has now been set for the getBalance resource. Click Save
© 2015 Copyright IBM Corporation
Page 19 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Test the getBalance Resource
The integrated test tool provides the ability to test a resource from the API Manager UI. It is found within
the resource editor in an API.
32. Click APIs in the navigation pane. This will take you to the APIs listing.
© 2015 Copyright IBM Corporation
Page 20 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
33. Click on the AccountService API name to open the API editor.
34. Click on the Edit icon next to the getBalance resource.
© 2015 Copyright IBM Corporation
Page 21 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
35. Click the Test tab.
36. The Test fields should be correctly populated because there is only one Environment and
Plan defined from previous tutorials. If you have created additional Environments and Plans
since that tutorial then please ensure Sandbox and Sandbox (Version 1) are selected.
A sample SOAP request is generated with an input parameter for the account number that
can be optionally modified, highlighted in the below screenshot.
Click the Invoke button.
© 2015 Copyright IBM Corporation
Page 22 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
37. Confirm that the correct response was returned with a 200 OK response code .
38. As you have set a rate limit on the resource you can make the same request within a minute
to check that it is rejected as expected. This will return a 429 Too many Requests response
code. Click Invoke again.
© 2015 Copyright IBM Corporation
Page 23 of 24
Creating a SOAP API with IBM API Management 4.0.0.0
April 30, 2015
Summary
In this tutorial, you have built on top of the previous tutorials in this series and have learnt:



How to create a SOAP API definition
How to set a rate limit for a resource on a Plan
How to test that a rate limit is being enforced for a resource
This is the third in a series of tutorials which will cover the features of API Management 4.0. For
more information about this series and other tutorials please see:
http://developer.ibm.com/apimanagement
End of Tutorial
© 2015 Copyright IBM Corporation
Page 24 of 24