New York University

Computer Science Department

Courant Institute of Mathematical Sciences

 

Creating a Simple XML Web Service Using Visual Studio .Net

 

Course Title: Application Servers                                            Course Number: g22.3033-011

Instructor: Jean-Claude Franchitti                                            Session: 14

 

 

Software Requirements

 

Visual Studio .Net (includes VB.Net, C#.Net, and C++.Net).

 

Creating a New Web Service

 

Step 1: Open Microsoft Visual Studio.Net

 

 

Step 2: On the File menu, point to New, and click Project

 

Step 3: In the New Project dialog box, do the following

 

a.       In the Project Types pane, select Visual Basic Projects

 

b.      In the Templates pane, select ASP.NET Web Service

 

 

c.       In the Name box, type SimpleWebService as the name of your project

 

d.      In the Location box, you can accept the default setting, which is http://localhost, or you can enter a different URL

 

e.       Click OK

 

Step 4: In Solution Explorer, right-click the Service1.asmx file, and select View Code

 

Step 5: Scroll down below the commented (green) text, and add the code shown to

calculate the sum of numbers

 

Step 6: In Solution Explorer, right-click Service1.asmx, and click Set As Start Page

 

 

Step 7: Save the solution

 

 

Step 8: On the Build menu, click Build

 

Creating a Web Service Client Application

 

Step 1: On the File menu, point to New, and click Project

 

Step 2: In the New Project dialog box, do the following

 

a.       In the Project Types pane, select Visual Basic Projects

 

b.      In the Templates pane, select ASP.NET Web Application

 

c.       In the Name box, type WebApplication as the name of your project

 

d.      In the Location box, you can accept the default setting, which is http://localhost, or you can enter a different URL

 

e.       Click OK

 

 

Step 3: From the Web Forms tab of the Toolbox, drag and drop two TextBox controls, a

Label control, and a Button control to the Design page WebForm1.aspx, and

arrange them to your liking

 

 

Step 4: Right-click the Button control, and click Properties

 

Step 5: In the Properties window, set the Text attribute to Calculate

 

 

Step 6: Right-click the Label control, and click Properties

 

Step 7: In the Properties window, clear the Text attribute to make this label blank

 

Adding a Web Reference

 

Step 1: On the Project menu, click Add Web Reference

 

Step 2: In the Address box of the Add Web Reference dialog box, type the URL to the

.vsdisco file (i.e., http://localhost/SimpleWebService/SimpleWebService.vsdisco)

of the Web Service you want to access or click on the Web Reference on Local

Web Server link. When you obtain the discovery document, select the Web service you want in the Available reference box

 

Step 3: Click Add Reference to add a Web reference for the target Web service.

 

Accessing the Web Service

 

Step 1: Double-click the Calculate button on WebForm1.aspx to create an event-handling

method for this button and to display the code-behind file. Then add the code

shown below

 

Step 2: Select WebForm1.aspx in Solution Explorer

 

Step 3: Right-click the WebForm1.aspx, and then select Set as Start Page on the shortcut         menu

 

Step 4: Save the solution.

 

Building and Testing the Web Service Client Application

 

Step 1: On the Build menu, click Build

 

 

Step 2: In Solution Explorer, right-click Webform1.aspx, and click View in Browser

 

 

Step 3: In the two text boxes, type the numbers you want to multiply, and then click the Calculate button

 

 

 

Testing A Farenheit to Degree  Conversion Application

 

 

 

 

Comparing with the IBM WSTK Address Book Sample