Presentation is loading. Please wait.

Presentation is loading. Please wait.

IMS 4480: Introduction to Web Services 1 Dr. Lawrence West, MIS Dept., University of Central Florida Introduction to Web Services—Topics.

Similar presentations


Presentation on theme: "IMS 4480: Introduction to Web Services 1 Dr. Lawrence West, MIS Dept., University of Central Florida Introduction to Web Services—Topics."— Presentation transcript:

1 IMS 4480: Introduction to Web Services 1 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Introduction to Web Services—Topics Creating a Web Service Testing Web Services Referencing a Web Service in a Visual Studio Project Support for Web Services Solutions in Visual Studio

2 IMS 4480: Introduction to Web Services 2 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Creating a Web Service Create a new VS project of type “ASP.Net Web Service” You automatically have “Service1.asmx” as the default service. Rename this or delete it and add a new service giving it a meaningful name. You may have many web service files in a single solution –Break them up by functionality

3 IMS 4480: Introduction to Web Services 3 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Adding Code to the Web Service Add whatever methods, properties, etc., that you need to your web service Precede subroutines and functions that you want to expose to the web with the line: _ Public Function HelloWorld() As String Return "Hello World“ End Function Procedures lacking this prefix will be used internally within the service Note Line Continuation Character

4 IMS 4480: Introduction to Web Services 4 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Testing Web Services Web services can be tested without a consumer application Navigate to the services.asmx page Select the public method you wish to test

5 IMS 4480: Introduction to Web Services 5 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Testing Web Services (cont.) The CalcTotal function requires two parameters Test provides simple text boxes for input “Invoke” button tests the service

6 IMS 4480: Introduction to Web Services 6 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Testing Web Services (cont.) The result screen shows the XML-encapsulated result of the web service method/function _ Public Function CalcTotal(ByVal sglPrice As Single, _ ByVal intQty As Integer) As Single Return sglPrice * intQty * 1.06 End Function

7 IMS 4480: Introduction to Web Services 7 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Testing Web Services (cont.) You can also set the web services solution as the start up project in Visual Studio’s Solution Explorer Running the solution brings up the test page

8 IMS 4480: Introduction to Web Services 8 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Referencing a Web Service in a VB Project The VB client project (both Windows and ASP.Net) must be ‘aware’ of the capabilities of a web service you want it to use –Available methods and properties –Data types of parameters and return values This is done with a proxy class that contains this information

9 IMS 4480: Introduction to Web Services 9 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Adding Web Reference Right click project and select “Add Service Reference…”

10 IMS 4480: Introduction to Web Services 10 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Adding Web Reference (cont.) Click Advanced…

11 IMS 4480: Introduction to Web Services 11 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Add Web Reference (cont.) Click "Add Web Reference…"

12 IMS 4480: Introduction to Web Services 12 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Adding Web Reference (cont.) Find your web service in this solution

13 IMS 4480: Introduction to Web Services 13 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Add a Web Reference (cont.) Select the desired web service

14 IMS 4480: Introduction to Web Services 14 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Creating a Web Reference (cont.) Capabilities Name you will reference in code Click Add Reference

15 IMS 4480: Introduction to Web Services 15 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Special Note It is very, very important that you complete the web service before you add the reference to it in another web or Windows project The Web Reference freezes the interface of the web service at the time the reference was added to the project I have had a great deal of difficulty getting these references to recognize changes to the interface You can change coding within the web exposed functions and subs and other procedures with no problem

16 IMS 4480: Introduction to Web Services 16 Dr. Lawrence West, MIS Dept., University of Central Florida lwest@bus.ucf.edu Support for Web Services in Visual Studio Web services providers and consumers are multiple independent programs Visual Studio lets you work with both in one solution –Debug across programs –See code in both –Etc. Set Startup Project


Download ppt "IMS 4480: Introduction to Web Services 1 Dr. Lawrence West, MIS Dept., University of Central Florida Introduction to Web Services—Topics."

Similar presentations


Ads by Google