Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week Six : Writing Web Services Aims: Creating and Consuming student’s first Web Services Learning Outcomes: Familiarity with VS.NET for creating and consuming.

Similar presentations


Presentation on theme: "Week Six : Writing Web Services Aims: Creating and Consuming student’s first Web Services Learning Outcomes: Familiarity with VS.NET for creating and consuming."— Presentation transcript:

1 Week Six : Writing Web Services Aims: Creating and Consuming student’s first Web Services Learning Outcomes: Familiarity with VS.NET for creating and consuming web services Introduction to role of underlying protocols (WSDL, SOAP)

2 About web services A web service is a class that resides on a web server, whose methods and member variables may be accessed over the Internet Underlying communication between web service and consuming application is via XML The consuming application can create objects from a proxy of the web service class

3 Proxy? Something authorized represent another E.g. an ambassador A proxy class is a representation of the web service class

4 Web service described by description language WSDL (an xml schema) Client application uses WSDL to create a proxy class hence instantiate object Data exchanged via SOAP (simple object access protocol)

5 Creating a web service in Visual Studio.NET From IDE main menu select ‘File->New->Project’Visual C# Projects [ASP.NET Web Service] You inherit from the super class… System.Web.Services.WebService And all web accessible methods should be public and prefixed with… [WebMethod]

6 namespace HelloWorld { public class Service1 : System.Web.Services.WebService { //Some auto generated code [WebMethod] public string HelloWorld() { return "Hello World"; }

7 The Web Service Assembly Builds to a directory on ISS web server. –http://localhost/yourWebService Includes –Bin directory containing dll –a file with the suffix.asmx.

8 Testing your Web Service Can test the web service via –Debug->Start –or by typing the URL for it’s asmx file directly into a web Browser From the subsequent test web page can [Invoke] the method The output will be in XML, for example… Hello World

9 Consuming XML Web Service Consuming – i.e. using the web service Web services can be consumed by –Client side Windows Applications –Server side Web Applications –Other web services

10 Consuming with Visual Studio.NET Create a new project (e.g. Windows Application) From main menu select… Project->Add Web Reference … takes URL of web service http://your_host’s_url/WebService1/Service1.asmx Visual Studio uses the Web Service’s WSDL to create a proxy class Hence you use this class to instantiate Web Service object WebReference1.Service1 myws=new WebReference1.Service1();

11 Exercise 6.1 –Create your first XML Web Service Exercise 6.2 –Consuming your first XML Web Service Exercise 6.3 –Extend web service


Download ppt "Week Six : Writing Web Services Aims: Creating and Consuming student’s first Web Services Learning Outcomes: Familiarity with VS.NET for creating and consuming."

Similar presentations


Ads by Google