new york university computer science department courant ...instructor: jean-claude franchitti...

23
New York University Computer Science Department Courant Institute of Mathematical Sciences Creating a Simple XML Web Service Using Visual Studio .Net Course Title: XML for Java Developers Course Number: g22.3033-002 Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (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

Upload: others

Post on 18-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

New York University Computer Science Department

Courant Institute of Mathematical Sciences

Creating a Simple XML Web Service Using Visual Studio .Net

Course Title: XML for Java Developers Course Number: g22.3033-002 Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (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

Page 2: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 3: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 4: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

calculate the sum of numbers

Page 5: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 6: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes
Page 7: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

Step 7: Save the solution

Step 8: On the Build menu, click Build

Page 8: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes
Page 9: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 10: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 11: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

Step 4: Right-click the Button control, and click Properties Step 5: In the Properties window, set the Text attribute to Calculate

Page 12: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 13: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 14: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 15: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 16: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

menu

Page 17: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

Step 4: Save the solution. Building and Testing the Web Service Client Application Step 1: On the Build menu, click Build

Page 18: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Page 19: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

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

Calculate button

Page 20: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes
Page 21: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

Testing A Farenheit to Degree Conversion Application

Page 22: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes
Page 23: New York University Computer Science Department Courant ...Instructor: Jean-Claude Franchitti Session: 9 Software Requirements Visual Studio .Net Beta 2, Service Patch 2 (includes

Comparing with the IBM WSTK Address Book Sample