Home > Advanced Programming Techni... > Implementing Web Services > Example: Creating a Web Ser...
![]() Previous |
![]() Next |
In this example, you create a Web reference by supplying information about the Web service and using the manual facility. Manual Web references are created by visually inspecting the WSDL document as well as using a tool to determine the SOAP envelope for the Web service request.
Topics in this section include:
To create a Web reference manually, you copy sections from the WSDL for a service called MovieInformation.
Please note the example settings provided in the following steps are based on the MovieInformation service at the time this document was released.
To create a manual Web reference:
On the Application home page, click Shared Components.
Under Logic, click Web Service References.
Click Create.
Select Manual and click Next.
The Create/Edit Web Service page appears.
In the Name field, enter Movie Info
.
Locate the endpoint of the MovieInformation service:
Open the WSDL by going to:
http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl
In the WSDL, find the location
attribute of the soap:address
element, which is a child of the port
element. You can search for the following term within the code: soap:address location.
At the time of this release, it was this attribute:
http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx
In the URL field on the Create/Edit Web Service page, enter the endpoint of the MovieInformation service you located. For example: http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx
Locate the SOAP action for the GetTheatersAndMovies
operation:
If necessary, open the WSDL again. See Step 7a.
In the WSDL, find the soapAction
attribute of the soap:operation
element, which is a child of the operation element that has a name attribute of GetTheatersAndMovies
. You can search for the following term within the code: soap:operation soapAction
.
At the time of this release, it was this attribute:
http://www.ignyte.com/whatsshowing/GetTheatersAndMovies
In the Action field on the Create/Edit Web Service page, enter the SOAP action you located. For example: http://www.ignyte.com/whatsshowing/GetTheatersAndMovies
In the SOAP Envelope field on the Create/Edit Web Reference page, enter the xml document representing the SOAP Request message. For example:
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.ignyte.com/whatsshowing" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <soap:Body> <tns:GetTheatersAndMovies> <tns:zipCode>#ZIP#</tns:zipCode> <tns:radius>#RADIUS#</tns:radius> </tns:GetTheatersAndMovies> </soap:Body> </soap:Envelope>
You can use a SOAP message generating tool, such as MindReef, to construct a valid SOAP Request for a given Web service.
In the Store Response in Collection field, enter MOVIE_RESULTS
. This is where the response from the Web service will be stored.
The Create/Edit Web Service page should resemble Figure: Create/Edit Web Service Page.
Click Create.
The Web Service References page appears, showing Movie Info in the list.
To test the Web service reference:
On the Web Service References page, click the Test icon next to the Movie Info Web reference.
The Web Services Testing page appears.
Note: View must be set to Report, otherwise the Test icon is not displayed. |
In the SOAP Envelope field, replace #ZIP# with 43221
and #RADIUS# with 5
.
Click Test.
Review the Result field and note the following about the response:
The base node in the return envelope is called:
GetTheatersAndMoviesResponse
The namespace for the message is:
http://www.ignyte.com/whatsshowing
The XPath to the interesting parts of the response under the result element is:
/GetTheatersAndMoviesResponse/GetTheatersAndMoviesResult/Theater/Movies/Movie
The interesting elements in the results are called:
Name Rating RunningTime ShowTimes
Next, you create a page that contains a form and report to use with the Manual Web Service Reference.
To create a form and report on a Manual Web Service Reference:
On the Application home page, click Create Page.
Select Form and click Next.
Select Form and Report on Web Service and click Next.
For Web Service Reference, select Movie Info and click Next.
For Page and Region Attributes, make these changes:
Form Region Title - Enter Theater Information
.
Accept all other defaults and click Next.
For Input Items, make these changes:
For ZIP and RADIUS, accept the default, Yes, in the Create column.
For ZIP, change the Item label default to ZIP Code.
Click Next.
For Web Service Results, make these changes:
SOAP Style - Select Document.
Message Format - Select Literal.
Result Node Path - Enter the following:
/GetTheatersAndMoviesResponse/GetTheatersAndMoviesResult/Theater/Movies/Movie
Message Namespace - Enter the following:
http://www.ignyte.com/whatsshowing
Click Next.
For Parameter Names, enter Name
, Rating
, RunningTime
, and Showtimes
and click Next.
For Tab Options, accept the default and click Next.
Click Create Form and Report.
Click Run Page.
If prompted to log in, enter the user name and password for your workspace and click Login.
A form and report resembling Figure: Theater Information Form and Report without Data appears. Notice that the Theater Information Form at the top of the page contains a data entry field and a submit button, but the Results Report does not contain any data.
Theater Information Form and Report without Data
To test the form, enter 43221
in the ZIP Code field and 5
in the Radius field. Then click Submit.
The report at the bottom of the page should resemble Figure: Theater Information Report Showing Resulting Data. The report lists the names and addresses of movie theaters matching the entered ZIP code and radius.
Theater Information Report Showing Resulting Data