Build a user interface
Now we know how our web service works we can think about integrating
it into our site. There are a range of possibilities for even the
simplest of web services.
It could be that our web service will be called using a fixed set of
parameters and we simply display the latest result of calling the web
service. For example, a website for a nature park may display the
current weather for the location of the park integrated within the web
site.
Another possibility is that some of the parameters may be fixed, but
the user of your website may need to provide the remaining ones. For
example, a foreign visitor to your site may enter their currency code on
you web page and the page will determine the conversion rate from GB
Pounds.
At the other extreme there is the totally generic user interface
which allows the user to enter all the parameters so that the page can
perform the function. For example, a language translation site may
provide the user with a list of source languages and destination
language and provide a space to type some text. The page will call the
web service and return the translation.
It is up to you to determine how the interface is constructed. Bear
in mind that the developer who writes the call to the web service will
provide the link between your input elements and the result.
Example 1: Return the current temperature for a fixed location
This is the simplest of user interfaces. The web page developer
provides an <asp:Label> element on the web page in the required
location. The application developer will create code to call the web
service and drop the result in the label.
Example 2: Return the latest conversion rate to an arbitrary
currency
Here the web page design should allow for a drop down list for the
user to select their currency. The local currency will always be GBP. An
<asp:Label> or perhaps a read-only <asp:TextBox> will be placed on the
page to receive the conversion rate. There may be a button to trigger
the lookup or the page may automatically lookup when a currency is
selected in the drop down list. The application developer writes the
code to pass the value from the drop down list and GBP to the web
service and place the result on the page.
Example 3: Generic page for translating text.
We can provide a drop down list for selecting one of the translation
types. A multiple line text box is provided for the user to type text
into (or paste). A button to action the translation is required and a
multi-line label for receiving the result of the translation. All the
parameters are available on the page for the developer to use when
calling the web service. The result is dropped into the label.