Web Services Introduction - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Web Services Introduction

Description:

Web Services Introduction ISYS 546 Web Service XML Web Service Web services are classes that are stored on the web which can instantiate and use in both Windows and ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 16
Provided by: COB84
Learn more at: https://faculty.sfsu.edu
Category:

less

Transcript and Presenter's Notes

Title: Web Services Introduction


1
Web Services Introduction
  • ISYS 546

2
Web Service
  • XML Web Service
  • Web services are classes that are stored on the
    web which can instantiate and use in both Windows
    and Web applications.

3
Creating a Web Service Using a Text Editor
  • WebService directive
  • lt_at_ WebService Class"CustomerInfo" gt
  • Import namespaces
  • imports System.Web.Services
  • imports System
  • Define the web service class.
  • Add WebMethod attribute to the function
    declaration.
  • Note Web service file extension is ASMX

4
A Web Service ExampleASPET/TestWebService.ASMX
lt_at_ WebService Class"CustomerInfo" gt imports
System.Web.Services imports System imports
System.Data imports System.Data.Oledb Public
Class CustomerInfo ltwebMethod()gt public Function
GetCname(ByVal CID as String) as String dim
strConn as string "ProviderMicrosoft.Jet.OLEDB.4
.0Data Source c\sales2k.mdb" dim objConn as
new OledbConnection(strConn) dim strSQL as
string "select from customer where CID '"
CID "'" dim objComm as new
OledbCommand(strSQL,objConn) dim Results as
string objConn.open() dim objDataReader as
oledbDataReader objDataReaderobjComm.executeRea
der() objDataReader.read() return
objDataReader("Cname") end function
5
Creating a Web Service Using VS
  • New Project/ASP.Net Web Service

6
Web Service Description Language (WSDL)
  • A WSDL file is an XML document containing a
    complete description of the web service. It
    shows a web services name, methods, and
    parameter types.
  • Help page After entering web services URL, a
    help page is displayed. You can click the
    Service Description link to see the WSDL file.

7
HTTP
  • HTTP Request
  • Request line Method Get, Post
  • Header
  • Body
  • HTTP Response
  • Respons line HTTP version and status code
  • Header
  • Body

8
Invoking a Web Service with HTTP
  • Http Get
  • http//dchaolaptop/aspnet/testwebservice.asmx/GetR
    ating?cid1
  • Http Post
  • Use the Action attribute to call the function.
  • Http-SOAP Use Https Post method to send an XML
    document in Https body section.
  • Demo Help page

9
Simple Object Access ProtocolSOAP
  • SOAP Request and Response message
  • Envelop An envelop element surrounds the
    message. It is the root element of a SOAP XML
    document.
  • Body
  • Request Contains the method call name and
    parameter names and values.
  • Response Contains the results returned by the
    method.

10
Consuming Web Services from a Windows Application
  • Add a web reference to the web service.
  • Declare a web service class variable.
  • Dim myWebService As New dchaolaptop.CustomerInfo()
  • Demo UseWebService

11
Universal Description, Discovery, and Integration
(UDDI)
  • A directory service for web services.
  • http//uddi.org

12
Consuming Web Services from a Web Application
  • Creating a web service proxy class
  • A local representation of the web service.
  • Steps to creating a proxy class
  • Use the Wsdl.exe tool to generate the source code
    file for the proxy class.
  • Compile the source code file into a DLL file.
  • Copy the DLL file to the applications Bin folder.

13
Use the Wsdl.Exe Tool to Generate the Source Code
File
  • Issue the wsdl.exe command at the Visual Studio
    command prompt
  • Start/Programs/microsoft VS .Net/VS .Net Tools/
    VS .Net Command prompt
  • The following command example create a
    CustomerInfo.vb file for the testwebservice.asmx
    web service.
  • wsdl.exe /lvb http//dchaolaptop/aspnet/testwebs
    ervice.asmx?wsdl

14
Compile the Source Code File Into a DLL File
  • The command below create a CustomerInfo.dll
  • Vbc /tlibrary /rsystem.dll,system.web.services
    .dll,system.xml.dll CustomerInfo.vb

15
ltscript runat"server"gt sub CallService(s as
object, e as eventArgs) dim myProxy as new
CustomerInfo lblCname.textmyProxy.GetCname(txtCID
.text) lblRating.textmyProxy.GetRating(txtCID.tex
t) end sub lt/scriptgt lthtmlgt lt/headgt ltbodygt ltform
runat"server"gt Enter CID ltasptextbox
id"txtCID" runat"server" /gt ltasplabel
id"lblCname" runat"server"/gt ltasplabel
id"lblRating" runat"server"/gt ltaspbutton
text"GetService" onClick"CallService"
runat"server" /gt lt/formgt lt/bodygt lt/htmlgt Demo
testProxy.aspx
Write a Comment
User Comments (0)
About PowerShow.com