Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol.

Similar presentations


Presentation on theme: "1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol."— Presentation transcript:

1 1 CS 3870/CS 5870: Note 13 Web Service

2 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol XML MS.NET Remoting

3 3 Creating Web Service Add New Items for the web site Web Service File UWPCSSEWebService.asmx File UWPCSSEWebService.vb under App_Code

4 4 Web Service Namespace At the beginning of UWPCSSEWebService.vb Default http://tempuri.org/ Change to https://xray.ion.uwplatt.edu/YourUserName/

5 5 Web Service Class _ Public Class UWPCSSEWebService Inherits System.Web.Services.WebService ‘ An example of web method _ Public Function HelloWorld() As String Return "Hello" End Function End Class

6 6 Looking at Web Service Go to the Web Service URL: https://xray.ion.uwplatt.edu/YangQ/UWPCSS EWebservice.asmx

7 7 Web Service Class _ Public Class UWPCSSEWebService Inherits System.Web.Services.WebService ‘ Create new web methods _ Public Function WS_GetAllProducts() As Data.DataTable ‘ May need to setup adapter DataClass.tblProducts.Clear()‘Should have this! ‘ Return the datatable End Function End Class

8 8 Web Service Class _ Public Class UWPCSSEWebService Inherits System.Web.Services.WebService ‘ Create new web methods Public Function WS_GetAllProducts() As Data.DataTable ‘ May need to setup adapter DataClass.tblProducts.Clear()‘Should have this! ‘ Return the datatable End Function End Class Will not Work!

9 9 Consuming Web Service Adding Web Reference Invoking Web Service from client application

10 10 Adding Web Reference Right click the root of the Web Site Add Service Reference Enter the URL of the wanted web service followed by “?WSDL” https://xray.ion.uwplatt.edu/CS3870/UWPCSSEWebservi ce.asmx?WSDL Namespace UserName (Web Site Name, e.g. CS3870)

11 11 Web Config The Web Config file will be updated automatically with the following. ‘ May not have the following <endpoint address="https://xray.ion.uwplatt.edu/CS3870/UWPCSSEWebservice.asmx" binding="basicHttpBinding" bindingConfiguration="UWPCSSEWebServiceSoap" contract="CS3870.UWPCSSEWebServiceSoap" name="UWPCSSEWebServiceSoap" />

12 12 Selecting Web Services Dim ws As String Dim obj As Object If ws = "CS3870" Then ‘obj = New CS3870.UWPCSSEWebService obj = New CS3870.UWPCSSEWebServiceSoapClient ElseIf ws = "yangq" Then obj = New yangq.UWPCSSEWebServiceSoapClient End If Session("WS") = obj

13 13 Invoking Web Methods Dim obj As Object Dim myTable As Data.DataTable Protected Sub Page_Load(...) Handles Me.Load obj = Session("WS") myTable = obj.WS_GetAllProducts() Session("WS_Table") = myTable GridView1.DataSource = myTable GridView1.DataBind() End Sub

14 Session Variables Record_Index Page_Index Table 14

15 Accessing Table From Web Service No Credit if Still Accessing Local Table 15

16 Pages Default and SelectingWS Must select WS first Page Default Protected Sub Page_Load(...) Handles Me.Load If Session("WS") Is Nothing Then 'Server.Transfer("~/Lab6/SelectingWS.aspx") Response.Redirect("~/Lab6/SelectingWS.aspx") End If... End Sub 16

17 Not Working Delete and Create Service Reference? 17


Download ppt "1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol."

Similar presentations


Ads by Google