| |
| XML Web Services |
| 'Subtract' WebMethod |
In this walkthrough, you will create a new
WebMethod that returns a simple type; an Integer representing
the difference of two numbers.
- Open the myFirstWebService.asmx file in Code view.
- Add code for a WebMethod called Subtract. The function
has two input parameters and one output parameter containing the
difference of the two input parameters. All parameters are of type Integer:
<WebMethod> Public Function Subtract(a As Integer, b As Integer) As Integer
Return a - b
End Function
- Save and run the XML Web Service (hit the start button or press
F5 to launch it).
- A dynamically generated page describing your XML Web Service will
automatically appear in a new instance of your Web browser.
- You will see the XML Web service's HTML description file, containing
two methods (Add and Subtract).
- Click the Subtract link at the top of the HTML description
file. This will bring up a details page about the Subtract web method --
including schema details about the SOAP payload used to invoke it, as well
as an HTML form to invoke and test the method.
- Enter 8 in the a parameter box.
- Enter 3 in the b parameter box.
- Click Invoke.
- The Web service will return an XML response that gives the difference
of the two input parameters in a new instance of your Web browser.
- Close the Web browser instance.
Next Step >> |
|