Tutorial: Defining a User Registration Web Service
The purpose of this tutorial is to demonstrate how to create an OAGIS style Web services that will create a new customer in WebSphere Commerce through Web services using the WebSphere Commerce Web services framework. This tutorial will demonstrate the steps involved in defining a new service that uses the OAGIS style to create a new customer, register the service in WebSphere Commerce and create the response JSP template to generate a confirmation response.
In this tutorial, a SyncCustomer service will be created. This service will follow the XML schema conventions set by OAGIS (http://www.openapplications.org) but will not exploit the OAGIS schema elements for simplicity. This service will define an XML schema that will represent an existing business logic operation of registering a new user (UserRegistrationAdd). Using the Web services framework, the service will delegate to the existing business logic to create a new user and use a JSP template to return the internal identifier of the user along with the user's distinguished name. At the end of this tutorial, there will be a Web service that can be used by external applications to create users in WebSphere Commerce.
Learning objectives
This tutorial highlights the following features of the Web services framework:
- Define an OAGIS style Web service
- Call existing business logic
- Create a success confirmation message
- Create a custom failure message
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
IBM recommends that you also follow the tutorial to define a Web service to retrieve product information.
ResourcesDownload the zip file containing all the code relating to this tutorial.
Lessons in this tutorial
- Define the SyncCustomer schema
This section describes the steps involved in creating a new XML schema definition. The XML schema will define a Web service to create customers. Since this tutorial follows the OAGIS structure, the directories in which the XML schema is placed will follow the OAGIS overlay recommendation. After completing this section, we will have an XML schema that is used to define the Web services.
- Define the WSDL
This section describes how to expose the SyncCustomer schema as a Web service. The Web service defined in this tutorial is a customer service which is represented by the SyncCustomer message. Furthermore, this Web service will respond with an OAGIS ConfirmBOD that contains an acknowledgement that a customer was created.
- Map a WSDL document to the WebSphere Commerce Web Services Framework
This section is related to mapping a WSDL document to the WebSphere Commerce Web Services framework.
- Configure message mapping for a Web service request
This section describes how to enable 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 ConfirmBOD responses JSP page
When executing the business logic, there are two types of responses that can be returned. Both responses comply with the OAGIS ConfirmBOD schema definition but only one response is used to show a successful execution of the service operation while the other represents a failure of the service operation. In the case of a successful operation, the confirmation response would return the internal WebSphere Commerce identifier of the customer and, in the case of a failure operation, the confirmation should indicate the error for why the request failed. In this section, the process of defining both JSP templates will be described.
- Register a Web service response JSP page with WebSphere Commerce
This section is related to registering a Web service response JSP page with WebSphere Commerce.
- Test Web SyncCustomer service
The following Java application can be used to test the Web service. This application uses the content of the input.xml file as the body of the Web service request and makes the request. When the response is received, the application will print out the SOAP body of the Web service response.
- Define a User Registration 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