Tutorial: Defining an inbound Web service
This tutorial demonstrates how to create a Web service to retrieve information.
Learning objectives
Although WebSphere Commerce promotes using an OAGIS style schema to define services ( http://www.openapplications.org/), for simplicity this example uses simple XML schema to create a product service to retrieve product information. The WebSphere Commerce Web services framework will operate regardless of how the services are defined.
In this tutorial we will use WebSphere Commerce Developer to develop a Web service that uses the WebSphere Commerce Web services framework. You will learn how to perform the following tasks:
- Develop a Web Service definition
- Set up the WebSphere Commerce Web services framework to handle the request
- Create a JSP page to generate the Web service response
- Set up a caching policy to cache fragments of the Web service response
Time required
Expect this tutorial to take about 3 hours to complete.
Audience
This tutorial is intended for WebSphere Commerce developers who will be responsible for developing Web services.
Prerequisites
Configure WebSphere Commerce Developer for Web service developmentBefore beginning this tutorial, ensure that you have configured WebSphere Commerce Developer for Web service development.
You must enable Struts Development in WebSphere Commerce Developer, if it is currently disabled:
- Select Window > Preferences.
- Select General > Capabilities.
- Click Advanced... and select Web Developer (advanced) > Struts Development, if it is currently disabled.
- Click OK to accept the changes and close the Advanced Capabilities Settings window.
- Click OK to accept the changes and close the Preferences window.
Knowledge prerequisitesBefore beginning this tutorial ensure that you have:
- Knowledge of the XML schema editor
- Knowledge of the WSDL editor
See the following technotes if you have problems with the validation of the XML Schema Definition (XSD) when using WebSphere Commerce Developer.
- http://www-1.ibm.com/support/docview.wss?uid=swg21228887
- http://www-1.ibm.com/support/docview.wss?uid=swg21221949
Lessons in this tutorial
- Prepare the workspace
The WebServicesRouter project contains all files that are used to define Web services. You should place all the WSDL (Web Services Description Language) and XSD (XML Schema Definition) files in this project.To develop a new Web service or modify an existing Web service definition, use the files in the WebServiceRouter project under the WebContent folder. The WebContent folder contains wsdl and xsd folders. To reuse the schemas in other Web service definitions, separate the schema from the WSDL file.
- Create the XML schema for a Web service
In this section you create the XML schema for a Web service.
- Create the WSDL document for a Web service
This section contains the recommended steps for creating a WSDL document to expose the XML schema as a Web service.
- Map the WSDL document to the WebSphere Commerce Web services framework
Enabling the WebSphere Commerce Web services framework to handle the WSDL document involves two parts. The first part, described in this section, is to configure the WebSphere runtime environment to map the Web service request to the WebSphere Commerce Web services framework. The second part, described in Step 6, is to configure message mapping to process a Web service request.
- Configure message mapping for the Web service request
This section describes the second part of enabling the WebSphere Commerce Web services framework to handle the WSDL document. Now that you have mapped the WSDL document to the WebSphere Commerce Web services framework, you are ready to configure message mapping to process a Web service request.
- Create a Web service response JSP page
The WebSphere Commerce Web services framework uses JSP pages to create the responses to the Web service requests. The JSP pages generate the response document that matches the Web service definition. In creating response JSP pages, two activities are involved. One activity (described in this section) is creating the JSP template to generate the Web service response. The other activity (described in the next section) is registering the JSP page in the Struts configuration so that it can be picked up by the WebSphere Commerce Web services framework.
- Register a Web service response JSP page with WebSphere Commerce
This section describes the second activity in creating response JSP pages. Now that you have created JSP template to generate the Web service response, you are ready to register the JSP page in the Struts configuration so that it can be used by the WebSphere Commerce Web services framework.
- Add caching support for a Web service response JSP page
This section is related to adding caching support for a Web service response JSP page.
- Test the Web service
This particular sample uses a simple XML schema to define the Web service, so Web Services Explorer provides the easiest way to test the service.
- Define an inbound Web service summary
This section summarizes the tutorial.
Related concepts
WebSphere Commerce as a service provider
Related tasks
Configure WebSphere Commerce Developer for Web service development
Enable WebSphere Commerce as a service provider
Related reference
WebServicesRouter Web module configuration