When a JavaScript client
API is generated from an integration service, a JavaScript developer can use the JavaScript client API to call
the integration service from
an application that is running in a JavaScript environment.
About this task
Complete the following steps to call an integration service from a JavaScript application:
Procedure
- Understand the conventions that you must use, and the limitations
that you must be aware of, when you write an application
that uses the JavaScript client
API to call an integration service;
see JSON conventions for calling an integration service by using a JavaScript client API.
- Obtain the integration service URL
from the IBM Integration Bus
integration service developer
or administrator, or complete the following steps:
- In the IBM Integration Toolkit,
click the deployed integration service in the
Integration Nodes view.
- Click the Properties tab.
The
integration service URL
is listed in the Info section.
Note: The integration service URL is available
only when the integration service has a
SOAP/HTTP binding.
- Access the integration service URL
by using a web browser, and click the JavaScript
Client API link.
A
web page is displayed. The web page contains the following items:
- A link to the JavaScript
client API file, which you can download
(if you are developing a Node.js application)
or reference (if you are developing a web browser-based JavaScript application). You
can then use the JavaScript
client API file to access the integration service.
- Details of the JavaScript
client API methods of the integration service operations, which
include the input and output objects.
- Details of the errors that might be returned from the integration service.
- Sample code that you can add to your JavaScript application to call the JavaScript client API
methods of the integration service
operations, and to process any errors that are returned
from the integration service.
For more information about the contents of the web page, see Integration service web page.
- Optional: If you are developing a Node.js application,
then complete the following steps:
- Use the Node.js package manager (npm) to install the
Dojo package by changing to the Node.js
installation directory and typing the following
command on the command line:
- Download the service_name.js
JavaScript client
API file from the web page, where service_name is
the name of the integration service.
- Create a Node.js application that imports the downloaded JavaScript client API
file.
- Specify the host name and port of the integration service; see Specifying the host name and port of the integration service.
- Optional: If you are developing a web browser-based JavaScript application, then
complete the following steps:
- Create a web browser-based JavaScript application.
- Reference the dojo.js module and
the JavaScript client
API file for the integration service; see Referencing the dojo.js module and the JavaScript client API file.
- Use the information on the integration service web page to help
you complete the following tasks:
- Create the input objects for the JavaScript client
API methods of the integration service
operations.
- Use the sample code in your JavaScript application
to access the JavaScript client
API methods of the integration service operations.
- Add code to your JavaScript application
that handles the errors that might be returned from the integration service, and interrogates
the errors for the information you require.
Results
You can write a JavaScript application to
call an existing integration service.