Chapter 28 Quick Reference


Chapter 28 Quick Reference

To

Do this

Create a Web service.

Use the ASP.NET Web Service template. Use the WebService attribute to specify the namespace used to uniquely identify the Web service to the outside world. Tag each method you want to expose with the WebMethod attribute.

Test a Web service.

Right-click the .asmx file in the Solution Explorer and click View in Browser. Internet Explorer runs, moves to the Web service URL, and displays the test page. Click the link corresponding to the Web method you wish to run. On the Web method test page, enter values for the parameters and click Invoke. The Web method will run and generate a SOAP response that will be displayed in Internet Explorer.

Pass complex data as Web method parameters and return values.

Define a class to hold the data. Ensure that each item of data is accessible either as a public field or through a public property that provides get and set access. Ensure that the class has a default constructor (which might be empty).

Add a Web reference to an application and create a proxy class.

On the Project menu, click Add Web Reference. Either type the URL of the Web service in the Address text box at the top of the dialog box, or click the “Web References on local Web server” link and locate the Web service. Click Add Reference to create the Web service proxy.

Invoke a Web method synchronously.

Create an instance of the proxy class; it will reside in a namespace named after the Web server hosting the Web service unless you changed it when adding the Web reference. Run the Web method using the proxy class.




Microsoft Visual C# 2005 Step by Step
Microsoft® Visual C#® 2005 Step by Step (Step By Step (Microsoft))
ISBN: B002CKYPPM
EAN: N/A
Year: 2005
Pages: 183
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net