Web Service Example 3: RPC-Oriented Method with a Complex Type Parameter Based on a Domain with Allowed Values

Previous Next

First complete Web Service Example 1: RPC-Oriented Method with Simple Type Parameters. This example is an add-on.

In this example, you extend the TRAVELSERVICE web service provider with an RPC-oriented InsertTour method that inserts a Tour record.

One of the inserted column values is a maximum age. The corresponding AGE domain has four allowed values. You have to write an XML Schema (XSD) definition to let the client application know that these restrictions exist.

To define an RPC-oriented method that inserts a Tour record:

1.In the Web Services (Provider) window, query the TRAVELSERVICE web service provider that you defined in Example 1.
2.On the Methods tab page, define a InsertTour method, set the Operation Style to: RPC-oriented, and set the Method Call to: Synchronous.
3.Define SQL statement:

INSERT INTO TOUR(destination,tour_type, num_days, max_age)

VALUES

(

:destination,

:tour_type,

:num_days,

:max_age

)

 

4.Click the Check button, and in the Question dialog, click Yes.
Four input parameters are generated.
5.From the Definer menu, select: Define, Web Services Provider, Namespaces. Define a Namespace:

 Namespace Alias: InsertTour

 Namespace: urn:InsertTour

 Location: http://MyWebServer/TravelService/InsertTour.xsd

 

6.Define an InsertTour.xsd XML schema file that describes the structure of the returning XML document. This XML schema file is described in Web Service Example 3: XML Schema Definition for an AGE type with Allowed Values.
7.For the InsertTour method, change some attributes of the max_age input parameter:
Change the Domain to: AGE.
Change the Namespace Alias to: InsertTour.
Click the XML Data Type button and select the Age record.
This parameter is based on a domain with an IO Format other than: XML. The parameter name (max_age), is not included in the XML document. USoft automatically handles the parameter name.
8.Save your changes.
9.Click the Create Web Service button.
The web server publication folder now contains an up-to-date TRAVELSERVICE.ashx and web.config files.
10.Click the Create WSDL File button.
The web server publication folder now contains an up-to-date TRAVELSERVICE.wsdl file.
11.Restart the Rules Service for the TRAVEL application that you configured in Example 1.
12.From the Definer catalog, open the TRAVELCOMPONENT Web Service Component that you defined in Web Service Example 1: Define a Web Service Component.
13.Click the Refresh button.
14.In the Refresh Web Service Component dialog, select the InsertTour method, and click OK.
A new INSERTTOUR method is added.
15.Open the application that contains the web service component, and in the SQL command dialog, issue SQL statement:

INVOKE TRAVELCOMPONENT.INSERTTOUR

WITH

SELECT 'AUSTRALIA','SCENIC',28,'<max_age>36</max_age>'

 

You will get an error message, because 36 is not an allowed value. If you execute the same statement with value 35, an insert takes place, including a commit by the web service provider.

See Also

Web Service Example 3: XML Schema Definition for an AGE type with Allowed Values