Web service example 4: Step-by-step instructions

Previous Next

This topic contains step-by-step instructions to complete Web Service Example 4: Document-Oriented Method with Simple Type Parameters.

To define a document-oriented method that retrieves Tour details for a specified destination and tour type:

1.In the Definer, 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 GETTOURSDocument method, set the Operation Style to: Document-oriented, and set the Method Call to: Synchronous.
3.Define SQL statement:

SELECT                '<DestinationResponse>'||destination||'</DestinationResponse>'        DestinationResponse

,                '<TourTypeResponse>'||tour_type||'</TourTypeResponse>'                        TourTypeResponse

,                '<NumDaysResponse>'||num_days||'</NumDaysResponse>'                        NumDaysResponse

,                '<DescriptionResponse>'||description||'</DescriptionResponse>'        DescriptionResponse

FROM                tour

WHERE                destination = USXSL.value(:DestinationRequest

,                '/ns:DestinationRequest'

,                'xmlns:ns="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl"')

AND                tour_type = USXSL.value(:TourTypeRequest

,                '/ns:TourTypeRequest'

,                'xmlns:ns="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl"')

 

4.Click the Check button, and in the Question dialog, click Yes.
All input and output parameters are generated. Output parameters get the names of the aliases in the SQL statement: DestinationResponse, TourTypeResponse,…
The XML Data Type of all (simple type) parameters is "string".
5.Save your changes.
6.Click the Create Web Service button.
The web server publication folder now contains an up-to-date TRAVELSERVICE.ashx and web.config files.
7.Click the Create WSDL File button.
The web server publication folder now contains an up-to-date TRAVELSERVICE.wsdl file.
8.Restart the Rules Service for the TRAVEL application that you configured in Example 1.
9.From the Definer catalog, open the TRAVELCOMPONENT Web Service Component that you defined in Web Service Example 1: Define a Web Service Component.
10.Click the Refresh button.
11.In the Refresh Web Service Component dialog, select the GETTOURSDocument method, and click OK.
A new GETTOURSDOCUMENT method is added.
12.Open the application that contains the web service component, and in the SQL command dialog, issue SQL statement:

INVOKE                TRAVELCOMPONENT.GETTOURSDocument

WITH

SELECT                '<DestinationRequest xmlns="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl">AUSTRALIA</DestinationRequest>'

,                '<TourTypeRequest xmlns="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl">ISLAND SUNTANNER</TourTypeRequest>'

 

All details of this record (if any) are returned, and are surrounded by the XML elements defined in the SQL Statement of the Web Service Provider. For example:

<ns1:DestinationResponse xmlns:ns1="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl">AUSTRALIA</ns1:DestinationResponse>

<ns1:TourTypeResponse xmlns:ns1="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl">ISLAND SUNTANNER</ns1:TourTypeResponse>

<ns1:NumDaysResponse xmlns:ns1="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl">13</ns1:NumDaysResponse>

<ns1:DescriptionResponse xmlns:ns1="http://MyWebServer/TravelService/TRAVELSERVICE.wsdl">Exclusive sailing adventure,to the Great Barrier Reef</ns1:DescriptionResponse>

 

For background information about all SOAP messages sent, refer to: Web service example 4: SOAP request and response messages.