outline - wmich.edualfuqaha/summer11/cs5950/... · uddi overview uddi = universal description,...

45
Web Services This material is based on the original slides of Dr. Mark Sapossnek, Computer Science Department, Boston University, Mosh Teitelbaum, evoch, LLC, and Joe Hummel, Lake Forest College Outline Web Services Overview Underlying Technologies Developing a Web Service Consuming Web Services Miscellaneous

Upload: others

Post on 06-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Web Services

This material is based on the original slides of Dr. Mark Sapossnek, Computer Science Department, Boston University, Mosh Teitelbaum, evoch, LLC, and Joe Hummel, Lake Forest College

Outline

Web Services Overview

Underlying Technologies

Developing a Web Service

Consuming Web Services

Miscellaneous

Page 2: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Companies, suppliers, partners, and customers must be able to work together

Faster than ever before

Over the Internet

Or risk “death by isolation”

Leverage Internet cost structure

Web Services Overview Drivers

Web Services OverviewWhat Is a Web Service?

A Web Service exposes functionality to a consumerOver the Internet or intranet

A programmable URL

Functions you can call over the Internet

Based on Web standardsHTTP, XML, SOAP, WSDL, UDDI, with more to come

Can be implemented in any language on any platform

Black boxesComponent-like, reusable

Page 3: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Web Services OverviewWhat Is a Web Service?

A Web Service combines the best features of distributed computing

Provides a mechanism for invoking methods remotely

Uses Web standards (e.g. HTTP, XML) to do so

Web Services OverviewWhat Is a Web Service?

Web Services allow you to interconnect:Different companiesMany/any devicesApplicationsDifferent clients

Not just browsers

Distribution and integration of application logicEnable the programmable Web

Not just the purely interactive Web

Web Services are loosely coupled

Page 4: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Web Services Overview Technology Fabric Must Span Companies

New paradigm for Internet development

Deliver applications as services

Richer, customer-driven experience

Continuous delivery of value/bits

Third-generation Internet

Web Services OverviewWhat is a Web Service?

Page 5: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Web Services OverviewEvolution of the Web

Generation 1

Static HTML

HTML

Generation 2

Web Applications

HTMLHTML, XML

HTML, XML

Generation 3

Web Services

Web Services Overview Benefits

EveryoneLeverage existing infrastructure

“Build or buy” development decisions

Minimize development time/costs

EnterprisesIntegration imperative

Dynamic, easy B2B relationships

New Web-based businessesGreater personalization

New services/new revenue streams

Be “everywhere” vs. single destination

Page 6: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Web Services Overview Possibilities

Scenario: Planning a tripGo to Expedia site (or Travelocity, or …)

Log in.

Find the flights you wantDon’t have to reenter seat/meal/airline/frequent flyer/… info

System can find lowest price fare by looking at your calendar(s)

Purchase tickets w/o entering credit card #

Flight info automatically added to your calendar and your spouse’s calendar

Book rental car/hotel w/your preferences; added to calendar

On day of trip get notified of flight status via email/toast/pager/cell phone

Other Web Services

Partner Web Service

Partner Web Service

Data Access and Storage Tier

Application Business Logic Tier

YourCompany.com

Internet + XML

Web Services OverviewApplication Model

Other Applications

End Users

Page 7: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Web Services OverviewSample Web Services

E-commerce: order books, office supplies, other products

Track packages: UPS, FedEx

Weather

Maps

Telephone redirection, customizable rules and messages

Outline

Web Services Overview

Underlying Technologies

Developing a Web Service

Consuming Web Services

Miscellaneous

Page 8: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Underlying TechnologiesXML Is the Glue

Program the Web

XML

Browse the Web

HTML

TCP/IP

Connect the Web

Technology

Innovation

Connectivity PresentationConnecting ApplicationsFTP, E-mail, Gopher

Web Pages Web Services

Underlying TechnologiesWeb Services Stack (Standards)

Ubiquitous Communications: Internet

Universal Data Format: XML

Wire Format: Service Interactions: SOAP

Description: Formal Service Descriptions: WSDL

Simple, Open, Broad Industry Support

Directory: Publish & Find Services: UDDI

Page 9: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Underlying TechnologiesWeb Services Stack

DiscoveryDirectory allows potential clients to locate relevant Web Services

UDDI

A Description language defines the format of methods provided by a Web Service

WSDL

Underlying TechnologiesWeb Services Stack

Directoryhttp://www.uddi.org

UDDI

WSDL

SOAP

Descriptionhttp://www.ibuyspy.com/ibuyspycs/InstantOrder.asmx?wsdl

Wire Format

Locate a Service

Link to Discovery Document (XML)

Return Service Description (XML)

Return Service Response (XML)

Request Service

Request Service Description

Web

Ser

vice

Clie

nt

UD

DI o

ro

ther

directo

ry service

Web

Service

Page 10: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Underlying TechnologiesWeb Services Stack

Directoryhttp://www.uddi.org

UDDI

DISCO

WSDL

SOAP

Inspectionhttp://www.ibuyspy.com/ibuyspy.disco

Descriptionhttp://www.ibuyspy.com/ibuyspycs/InstantOrder.asmx?wsdl

Wire Format

Locate a Service

Link to Discovery Document (XML)

Request Discovery Document

Return Discovery Document (XML)

Return Service Description (XML)

Return Service Response (XML)

Request Service

Request Service Description

Web

Ser

vice

Clie

nt

UD

DI o

ro

ther

directo

ry service

Web

Service

Web Service Protocols

Web services are based on four protocols:Extensible Markup Language (XML)

defines complex data structures

Web Service Description Lanaguage (WSDL)Specifies the interface of the web service

Discovery Protocol (DISCO)Pointer to all web services on a particular web site

Universal Description, Discovery, and Integration (UDDI)Central repository of web service descriptions

Page 11: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Underlying TechnologiesWeb Service Wire Format

The Web Service Wire Format specifies how specific messages are exchanged

HTTP-GETHTTP-POSTSOAP

HTTP-GET and HTTP-POST use a minimal HTTP interface to invoke Web Services

Limited support for data types

SOAP provides a robust HTTP/XML interfaceExtensive support for data types

XML is designed to represent and transfer structured data

In HTML: <p>Jan 15, 2000 </p>In XML: <OrderDate>Jan 15, 2000</OrderDate>

XML does not display or transform dataXML separates data from formatting and transforming

HTML and XML are both derived from SGMLIn different ways

XML OverviewXML Basics

Page 12: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

XML is composed of tags and attributesTags can be nested

Representing entities, entity properties, and entity hierarchy

<ROOT><Orders OrderID="10643" CustomerID="ALFKI" EmployeeID="6" OrderDate="1997-08-25T00:00:00" RequiredDate="1997-09-22T00:00:00" ShippedDate="1997-09-02T00:00:00" />

</ROOT>

XML OverviewXML Syntax

XML schemas describe the structure of an XML document

XML schemas describe the tag and attribute specifications

Simple and compound data types

XML schemas also describe constraints on the contained text

XML OverviewXML Schemas

Page 13: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

A lightweight protocol for exchanging information in a distributed, heterogeneous environment

It enables cross-platform interoperability

InteroperableOS, object model, programming language neutral

Hardware independent

Protocol independent

Works over existing Internet infrastructure

SOAP Overview

Guiding principle: “Invent no new technology”

Builds on key Internet standardsSOAP ≈ HTTP + XML

SOAP 1.2, W3C working draft

Tutorial:http://www.w3.org/TR/2002/WD-soap12-part0-20020626/

The SOAP specification defines:The SOAP message format

How to send messages

How to receive responses

Data encoding

SOAP Overview

Page 14: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Objects-by-referenceMessage-oriented

ComplicatedDoesn’t try to solve every problem in distributed computing

Can be easily implemented

SOAP SOAP Is Not…

SOAP Messages

A SOAP Message can be one of three types:Method call

Contains name of method and parameters

Method ResponseReturn values

Fault MessageSOAP fault message if service throws an exceptionWill get standard HTTP message if transport fails.

Page 15: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

SOAPThe HTTP Aspect

SOAP requests are HTTP POST requests

POST /WebCalculator/Calculator.asmx HTTP/1.1

Content-Type: text/xml

SOAPAction: “http://tempuri.org/Add”

Content-Length: 386

<?xml version=“1.0”?>

<soap:Envelope ...>

...

</soap:Envelope>

SOAP Message

SOAP Envelope

SOAP Header

SOAP Body

Message Name & Data

Headers

Headers

XML-encoded SOAP message name & data

<Body> contains SOAP message name

Individual headers

<Header> encloses headers

<Envelope> encloses payload

Protocol binding headers

The complete SOAP message

SOAPMessage Structure

Page 16: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

SOAPSOAP Message Format

An XML document using the SOAP schema:<?xml version=“1.0”?>

<soap:Envelope ...>

<soap:Header ...>

...

</soap:Header>

<soap:Body>

<Add xmlns=“http://tempuri.org/”>

<n1>12</n1>

<n2>10</n2>

</Add>

</soap:Body>

</soap:Envelope>

SOAPServer Responses

Server replies with a “result” message:

HTTP/1.1 200 OK...Content-Type:text/xmlContent-Length: 391

<?xml version=“1.0”?><soap:Envelope ...>

<soap:Body><AddResult xmlns=“http://tempuri.org/”>

<result>22</result></AddResult>

</soap:Body></soap:Envelope>

Page 17: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

SOAPEncoding Complex Data

Data structures are serialized as XML:

<soap:Envelope ...>

<soap:Body>

<GetStockDataResult xmlns=“http://tempuri.org/”>

<result>

<Description>Cisco Systems</Description>

<Price>49</Price>

<Ticker>CSCO</Ticker>

</result>

</GetStockDataRseult>

</soap:Body>

</soap:Envelope>

Builds on HTTP SecurityHTTPS

Developers / IT choose which methods to expose explicitly

Does not pass application code

Firewall-friendly

Type safe

SOAPSecurity and Features

Page 18: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Sun Microsystems

DevelopMentor Inc.

Digital Creations

IONA Technologies PLC

Jetform

ObjectSpace Inc.

Rockwell Software Inc.

SAP

Compaq

Microsoft

Rogue Wave Software Inc.

Scriptics Corp.

Secret Labs AB

UserLand Software Inc.

Zveno Pty. Ltd.

IBM

Hewlett Packard

Intel

SOAPIndustry Support

POST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset="utf-8"Content-Length: nnnnSOAPAction: "Some-URI“

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"SOAP-ENV: encodingStyle =

"http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body>

<m:GetLastTradePrice xmlns:m="Some-URI"><symbol>CSCO</symbol>

</m:GetLastTradePrice></SOAP-ENV:Body>

</SOAP-ENV:Envelope>

SOAPExample of a SOAP Request

Page 19: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

HTTP/1.1 200 OKContent-Type: text/xml; charset="utf-8"Content-Length: nnnn

<SOAP-ENV:Envelopexmlns:SOAP-ENV= "http://schemas.xmlsoap.org/soap/envelope/"SOAP-ENV: encodingStyle=

"http://schemas.xmlsoap.org/soap/encoding/"/><SOAP-ENV:Body>

<m:GetLastTradePriceResponse xmlns:m="Some-URI"><Price>34.5</Price>

</m:GetLastTradePriceResponse></SOAP-ENV:Body>

</SOAP-ENV:Envelope>

SOAPExample of a SOAP Response

HTTP/1.1 500 Internal Server ErrorContent-Type: text/xml; charset="utf-8"Content-Length: nnnn

<SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body>

<SOAP-ENV:Fault><faultcode> SOAP-ENV: MustUnderstand </faultcode><faultstring>SOAP Must Understand Error

</faultstring></SOAP-ENV:Fault>

</SOAP-ENV:Body></SOAP-ENV:Envelope>

SOAPExample of a SOAP Error

Page 20: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

XML schema for describing Web Services1. Service interface definition

– Abstract semantics for Web Service

2. Service implementation definition– Concrete end points and network addresses where Web

Service can be invoked

Clear delineation between abstract and concrete messages

WSDLWeb Services Description Language

WSDLWSDL Schema

ImplementationInterface

<portType>

<message>

<import>

<definitions>

<binding>

<types>

<port>

<import>

<definitions>

<service>

Page 21: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

WSDLWSDL Schema

Interface

<portType>

<message>

<import>

<definitions>

<binding>

<types>

• <definitions> are root node of WSDL

• <import> allows other entities for inclusion

• <types> are data definitions -xsd

• <message> defines parameters of a Web Service function

• <portType> defines input and output SOAP messages

• <binding> specifies how each message is sent over the wire

WSDLWSDL Schema

Implementation

<port>

<import>

<definitions>

<service>

• <service> specifies details about the implementation

• <port> contains the address itself

Page 22: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Open – allows for other namespaces and thus highly extensible

Ability to import other schemas & WSDL

Provides “recipe” for Web Services

Provides both interface and implementation details

Allows for separation of the two

WSDL WSDL Elements

WSDL Example

Example: Global Weather servicehttp://www.webservicex.net/globalweather.asmx?WSDL

Page 23: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

UDDIOverview

UDDI = Universal Description, Discovery, and Integration

Industry Initiative to address discoveryA registration database for Web Services

SpecificationsSchema for service providers and descriptions

API for publishing and searching

Developed on industry standards (XML, HTTP, TCP/IP, SOAP)

Applies to both XML and non-XML services

ImplementationPublic and private instances of specification

Marketplace

UDDIThe Vision

Search Portal

Marketplace

Search Portal

Marketplace

Business Users

Advanced Discovery via Portals and Marketplaces

UDDI Registries and Protocol

Technical Users

Page 24: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

UDDIUDDI Information Model

Provider: Information about the entity who offers a service

Service: Descriptive information about a particular family of technical offerings

Binding: Technical information about a service entry point and construction specs

tModel: Descriptions of specifications for services.

Bindings contain references to tModels. These references designate the interface specifications for a service.

0…n

0…n

1…n

UDDIUDDI Schema

Interface Implementation

<businessService>

<businessEntity>

<bindingTemplate>

<tModel>

<tModel>

<businessService>

<bindingTemplate>

Page 25: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

UDDIHow UDDI Works: tModel

tModel = Technology Model

Generic meta-data structure to uniquely represent any concept or construct

Also includes interface protocol definitions

Powerful abstraction modeling system

Examples: WSDL files, XML schema, namespaces, categorization schemes

UDDI<tModel>

<tModel> represents meta-data and interfaces<tModel xmlns="urn:uddi-org:api" tModelKey="UUID:AAAAAAAA-AAAA-

AAAA-AAAA-AAAAAAAAAAAA"><name>microsoft-com:creditcheck</name><description xml:lang="en">Check credit limits</description><overviewDoc>

<overviewURL>http://schema.com/creditcheck.wsdl</overviewURL>

</overviewDoc><categoryBag>

<keyedReferencetModelKey="UUID:CD153257-086A-4237-B336-6BDCBDCC6634" keyName="Consumer credit gathering or reporting services" keyValue="84.14.16.01.00"/>

<keyedReferencetModelKey="UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4" keyName="types" keyValue="wsdlSpec"/>

</categoryBag></tModel>

Page 26: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

UDDIProviders, Services And Bindings

ProvidersExamples: Accounting Department, Corporate Application ServerName, Description, Contact InformationCategorization and Identification Information

ServicesExamples: Purchase Order services, Payroll servicesName, Description(s)Categorization Information

BindingsDescription(s), access points, parametersExamples: Access Point (http://...) for Web Service

UDDI<bindingTemplate>

<bindingTemplate> represents data and implementation details

<bindingTemplate serviceKey="33c3d124-e967-4ab1-8f51-d93d95fac91a" bindingKey="48f2bc6b-a6de-4be8-9f2b-2342aeafaaac"> <accessPoint URLType="http">

http://localhost/HelloWorld/Service1.asmx</accessPoint><tModelInstanceDetails>

<tModelInstanceInfo tModelKey="uuid:64c756d1-3374-4e00-ae83-ee12e38fae63“/> </tModelInstanceDetails></bindingTemplate>

Page 27: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

UDDIImportant UDDI Features

Neutral in terms of protocols – as a registry, it can contain pointers to anything

Can search by business, service, Web Service (tModel), binding

Usage of Globally Unique Identifiers (GUIDs)

Specification allows public and private nodes

Delineation between interface and implementation

Outline

Web Services Overview

Underlying Technologies

Developing a Web Service

Consuming Web Services

Miscellaneous

Page 28: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Developing a Web ServiceBasics

Web ServiceImplemented in ASP.NET

Similar to Web Forms, but have a .asmx file extension

contains code, w/o UI

Lives in a virtual directory

Can have a code-behind

ASP.NET provides simple test harness

ASP.NET automatically generates WSDL

Can use .NET Framework classes and custom assemblies and classes

Developing a Web ServiceCode and Syntax

Codebehind

Inline (in C#)

<%@ WebService Language="c#" Codebehind="MyWebService.cs" Class="FirstWebService.MathService" %>

<%@ WebService Language=“C#“ Class=“MathService“ %>

using System.Web.Services;public class MathService : WebServices {

[WebMethod]public int Add(int num1, int num2) {

return num1 + num2;}

}

Page 29: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Developing a Web Service Examples

Example: MathService.asmx

Developing a Web ServiceTools

NotepadJust create a .asmx file

Visual Studio.NETCreate ASP.NET Web Service project

Page 30: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Creating a Web Service Project

Resulting “Generic” Web Service

Page 31: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Resulting “Generic” Test

DemoWebService Running

Web service description

Public web method

Page 32: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Client of DemoWebService

Instantiating web service

proxy Adding web reference creates proxy

SOAP Request and Response

Page 33: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

HTTP GET and POST exchanges

demo1.wsdl

Page 34: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Outline

Web Services Overview

Underlying Technologies

Developing a Web Service

Consuming Web Services

Miscellaneous

Consuming Web ServicesOverview

Locate the desired Web ServiceUDDIDISCO (Microsoft .NET specific)

Get detailed description of Web ServiceWSDL

Create a proxy that represents the Web ServiceProxy has the same methods/arguments/return values as the Web Service

Application instantiates and uses the proxy as if it were a local object

Page 35: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Consuming Web ServicesOverview

Web ServiceDeveloper

Web ApplicationDeveloper

Web Server S

Service App.asmx Web Server C

Service Application

Proxy.cs

Web Form.aspx

Create withWSDL.exe

Consuming Web ServicesOverview

Web Services are URL addressableHTTP request/response

Can request WSDL via URL

Can invoke via:HTTP-GET

HTTP-POST

HTTP-SOAP

Page 36: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Consuming Web Services Invoking via HTTP-GET

HTTP-GET

Result is an XML document

http://localhost//MathService.asmx/Multiply?a=11&b=11

<?xml version="1.0" encoding="utf-8" ?> <int xmlns="http://www.microsoft.com/MathService/">121</int>

Consuming Web Services Invoking via HTTP-POST

HTTP-POST

Result is an XML document

POST /MathService.asmx/Multiply HTTP/1.1 Host: localhostContent-Type: application/x-www-form-urlencodedContent-Length: length

a=11&b=11

<?xml version="1.0" encoding="utf-8" ?> <int xmlns="http://www.microsoft.com/MathService/">121</int>

Page 37: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Consuming Web Services Invoking: HTTP-SOAP

XML grammar forWebMethod, Method parameter, results

Supports all standard .NET datatypes and value classes

Additionally: classes, structs, datasets

Class and struct marshallingSerialization in XML format

Consuming Web Services Type Marshalling

Using HTTP-GET or HTTP-POSTPrimitive types

E.g. int, string, float, double, byte, …

Enum types

Arrays of primitives and enums

By-value only

Page 38: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Consuming Web Services Type Marshalling

Using SOAPPrimitive types

Enum types

Classes and structs

DataSet

XmlNode

Arrays of all of the above

By-value and by-reference are supported

Consuming Web ServicesTrying It Out

Request without method name or parametersASP.NET returns a page listing all methods

Click one of the methods and you can test it out

Specify parameters and InvokeOnly for primitive data types

Sample requests/responses

http://localhost/MathService.asmx

http://localhost/MathService.asmx?op=Multiply

Page 39: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Consuming Web ServicesTrying It Out

Request with parameter “WSDL”Formal WSDL description of Web Service

XML-based grammar

Can be used as input for wsdl.exe

http://localhost/MathService.asmx?WSDL

Consuming Web ServicesCreating a Proxy

Use wsdl.exe to generate a proxy

Creates MathService.cs

Contains MathService class, derived from SoapHttpClientProtocol in the System.Web.Services.Protocols namespace

Or HttpGetClientProtocol or HttpPostClientProtocol

You can instantiate these classes dynamically

Proxy embeds URL to the Web Service in the constructor

wsdl http://localhost/MathService.asmx?WSDL

Page 40: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Consuming Web ServicesUsing Visual Studio.NET

Use Add Web Reference to search UDDI or to discover Web Services given a URL

This builds a proxy, and you can start using the Web Service immediately

Visual Studio.NET essentially calls disco.exe and wsdl.exe for you

Adding a Web ReferenceYou have to locate the folder and asmx file, using explorer, then type in path here.

Page 41: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Create Proxy Source Code with WDSL.exe

Consuming Web ServicesExample

Example: TestServices.slnConsumes: MathService.asmx

Consumes: Global Weather Service

Page 42: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

Outline

Web Services Overview

Underlying Technologies

Developing a Web Service

Consuming Web Services

Miscellaneous

MiscellaneousState Management

Web Services are statelessUse ASP.NET session state mechanism

What is a session?Restricted to a logical applicationContext in which a user communicates to a server

FunctionalityRequest identification and classificationStore data across multiple requestsSession eventsRelease of session data

.NET State Server Process

Page 43: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

WebService

RMIService

DCOMService

Client

Firewall

Port 80

MiscellaneousHTTP and Firewalls

WebService

Client

WebService

Client

Raw HTTP

SSL

<soap:Body><AddResult xmlns= ...>

<result>28.6</result></AddResult>

</soap:Body>

<soap:Body>

<AddResult xmlns= ...> <result>28.6</result> </AddResult>

</soap:Body>

MiscellaneousSecure Sockets Layer

Page 44: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

MiscellaneousSecurity Model

Similar to securing a Web siteClients are computers and businesses

Possible options with IISIPSecBasicBasic over SSLDigestIntegratedClient certificatesPassport

Like ASP.NET Web FormsCOM+ services

COM+ automatic transactionsatomic, consistent, isolated, durable (ACID)

MiscellaneousTransactions

MSMQ Server

SQL Server

Application

COM+transaction context

Web Service

Page 45: Outline - wmich.edualfuqaha/summer11/cs5950/... · UDDI Overview UDDI = Universal Description, Discovery, and Integration Industry Initiative to address discovery A registration database

MiscellaneousTransactions

[WebMethod(Transaction=Transaction.Required)]

Transaction modesSupported

NotSupported

Required

RequiresNew

MiscellaneousExecution Model

SynchronousLike any other call to class methods

AsynchronousSplit the method into two code blocks

BeginMethodName

EndMethodName

xxxAsync()

CLR determines if operation has finishedCall Back Function