Creating Web Services Using ASP'NET - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Creating Web Services Using ASP'NET

Description:

... page is Service1.asmx.vb. asmx is the default extension ... Proxy class reads the WSDL to verify the Web service description. Proxy creates a SOAP envelope ... – PowerPoint PPT presentation

Number of Views:1000
Avg rating:3.0/5.0
Slides: 29
Provided by: C5038331
Category:
Tags: asp | net | class | creating | services | using | web

less

Transcript and Presenter's Notes

Title: Creating Web Services Using ASP'NET


1
Creating Web Services Using ASP.NET
  • Craig A. VanLengen
  • John D. Haney
  • Northern Arizona University

2
Service Oriented Architecture
  • Service Oriented Architecture (SOA)
  • Business-aligned services that support a
    flexible and dynamically re-configurable
    end-to-end business processes realization using
    interface-based service descriptions.
    http//searchwebservices.techtarget.com/originalCo
    ntent/0,289142,sid26_gci1006206,00.html
  • Software components are exposed as services over
    a network.
  • Applications are developed by selecting the
    appropriate components and gluing them together.
  • Services can be re-used to implement different
    applications.

3
SOA Layershttp//searchwebservices.techtarget.com
/originalContent/0,289142,sid26_gci1006206,00.html
4
Web Services
  • Services that are made available from a
    business's server for Web users or other
    Web-connected programs. http//searchwebservices.t
    echtarget.com/sDefinition/0,,sid26_gci934542,00.ht
    ml?trackJL-305
  • Standards used to create Web Services
  • XML eXtensible Markup Language
  • SOAP Simple Object Access Protocol
  • WSDL Web Services Description Language
  • UDDI Universal Description, Discovery and
    Integration

5
eXtensible Markup Language (XML)
  • Standard used to exchange a wide variety of data
    on the Web and elsewhere. http//www.w3c.org/XML/
  • Universal format for structured documents and
    data on the Web. http//www.w3c.org/XML/

6
Simple Object Access Protocol (SOAP)
  • Lightweight protocol intended for exchanging
    structured information in a decentralized,
    distributed environment. http//www.w3.org/TR/200
    3/REC-soap12-part1-20030624/
  • Defines a mechanism for communication with Web
    services over the Internet.
  • Format of messages
  • How HTTP can be used http//www.research.ibm.com/j
    ournal/sj/412/leymann.html

7
Web Services Description Language (WSDL)
  • An XML-based language that describes a service,
    including the protocols.
  • Standards for the description of error
    processing, object members, messaging, and other
    Web service behaviors. http//builder.com.com/510
    0-6373_14-5100498-2.html
  • Provides information necessary to invoke the Web
    service
  • Structure of the input and output messages

8
Universal Description, Discovery, and Integration
(UDDI)
  • A registry or listing of available services.
  • A phone book analogy is often used to describe
    UDDI.
  • Provides a listing of
  • Service type
  • Name of the company offering the service

9
Microsoft Visual Studio .NET
  • Visual Studio has a Web discovery service file
  • .disco
  • .wsdl
  • The Web service can be discovered from within
    Visual Studio .NET
  • With the Web reference in a project Web service
    objects can be used the same as local objects.

10
Web Service Example
11
Web Client Consuming a Web service
12
Example Specifications
  • Two Web services
  • dbService_CS.asmx.cs
  • dbService_VB.asmx.vb
  • Consuming application rmDemo.aspx
  • All programs developed using Microsoft Visual
    Studio .NET

13
Visual Basic Web Service
Create a new project and select a Web service
template. The default page is Service1.asmx.vb asm
x is the default extension used for a Web
service vb is the extension for a Visual Basic
code file. Imports System.Web.Services
ltWebService(Namespace"http//tempuri.org/")gt
_ Public Class VB_Service The default Web service
page includes the following commented code ' WEB
SERVICE EXAMPLE ' The HelloWorld() example
service returns the string Hello World. ' To
build, uncomment the following lines then save
and build the project. ' To test this web
service, ensure that the .asmx file is the start
page ' and press F5. ' 'ltWebMethod()gt Public
Function HelloWorld() As String ' HelloWorld
"Hello World" ' End Function
14
WebMethod
Note the function is prefaced by
ltWebMethod()gt This exposes the function as a
Web service ltWebMethod()gt Public Function
getProduct(ByVal srtType As String) As
DataSet 'This Service connects to the
database, 'and based on the argument sent, orders
the Product table by 'ID, Description, Price, or
Quantity and then returns the 'selected
dataset. Connection "ProviderMSDAORAPasswordo
raPWUser IDoraUserIDData Sourceoracba" Conn
New OleDbConnection(Connection)
15
Selection by Attribute
'Select from the database table If srtType "ID"
Then SQL "SELECT FROM Product Order by
ID" End If If srtType "Descr" Then SQL
"SELECT FROM Product Order by Description" End
If If srtType "Price" Then SQL "SELECT FROM
Product Order by Price" End If If srtType "Qty"
Then SQL "SELECT FROM Product Order by
Quantity" End If
16
Obtaining the results and Returning the dataset
object
Cmd New OleDbCommand(SQL, Conn) 'Open the
connection and establish the SQL
statement Conn.Open() 'Create an instance of the
adapter and dataset Adapter New
OleDbDataAdapter(Cmd) ds New DataSet() 'Fill
the dataset Adapter.Fill(ds, "Product") 'Return
the dataset Return ds End Function End Class
17
Creating Web Service Documents
A build (compile) of the Web service Creates the
Web service discovery file, Web Service
Description Language (WSDL) document XML
document Describes how to interact with the
service How to format and send data to the
service
18
Accessing Web Service Description
19
Accessing WSDL
20
Examine a sample SOAP request and response
21
Similar Service with C
using System.Web.Services namespace
rmWSCS public class CS_Service
System.Web.Services.WebService private
System.Data.OleDb.OleDbConnection Conn private
System.Data.OleDb.OleDbCommand Cmd private
System.Data.OleDb.OleDbDataAdapter
Adapter private System.Data.DataSet
ds private string Connection private string
SQL public CS_Service() //CODEGEN This
call is required by the ASP.NET Web Services
Designer InitializeComponent() WebMe
thod public DataSet getProduct(string
srtType)
22
Consuming the Web Service
  • Create a new project in Visual Studio .NET
  • ASP.NET Web Application, not a Web service.
  • Consuming application will be developed in Visual
    Basic.NET
  • rmDemo.aspx
  • rmDemo.aspx.vb
  • Add a Web Reference
  • Enter the URL of our Web Service server
    application.
  • Dialog shows the developer
  • WSDL
  • other documentation of the Web service.

23
Web Reference
  • Solution explorer window
  • Web Reference for the dbService_CS
  • .disco and .wsdl

24
Proxy Class
  • Proxy class is created when you build the
    consuming application
  • Uses the WSDL document
  • Proxy class reads the WSDL to verify the Web
    service description
  • Proxy creates a SOAP envelope
  • SOAP envelope passed to the Web service
  • Return value passed back to the proxy in a SOAP
    envelope over the HTTP connection.
  • Client Web application
  • Converts the SOAP XML response into the format
    required by the client
  • Dim dbServiceVB As vbService.VB_Service New
    vbService.VB_Service()
  • Dim dbServiceCS As csService.CS_Service New
    csService.CS_Service()

25
Instance of Database Service
'Create an instance of the database service
'that connects to the CIS440_Demo database
'and selects all of the rows and columns from
the Product table. Dim dbServiceVB As
dbService_VB.db_VB New dbService_VB.db_VB()
Dim dbServiceCS As dbService_CS.db_CS New
dbService_CS.db_CS() 'Dim dbServiceVB As
vbService.VB_Service New vbService.VB_Service()
'Dim dbServiceCS As csService.CS_Service
New csService.CS_Service() lblSet.Text
"Using " langType " Web Service, sorted by
" srtType
26
Filling DataSet from the Web Service Method
Dim ds As New DataSet() If langType
"C" Then ds dbServiceCS.getProduct(
srtType) Else ds
dbServiceVB.getProduct(srtType) End If
With dgProduct .DataSource
ds.Tables("Product") .DataBind()
End With
27
rmDemo Consuming a Web Service
28
Sources of Web Services
Abundant Technologies - IT Consulting
Experts http//www.abundanttech.com/index.htm XMet
hods http//www.xmethods.net/ CDYNE
http//www.cdyne.com/web-services.aspx Live Web
Services from Microsoft http//msdn.microsoft.com/
webservices/building/livewebservices/default.aspx
Microsoft Web Services Development
Center http//msdn.microsoft.com/webservices/build
ing/default.aspx
Write a Comment
User Comments (0)
About PowerShow.com