Embed
Email

WEB SERVICES

Document Sample

Shared by: xumiaomaio
Categories
Tags
Stats
views:
0
posted:
10/25/2011
language:
English
pages:
38
Web Services

Introduction

Web Services in .NET

SOAP

Service Description with WSDL

Preview of Web Services .NET 2.0

Summary

What are Web Services?

• Middleware for distributed applications

• For remote procedure calls and data

exchange

• Open standard based on XML

• For loosely coupled software services

• Independent of programming languages

and operating systems

• Utilizing existing Internet protocols and

server architectures

Definition Web Service (by W3C)

• Software application identified by URL

• interface description in XML

• interaction on the basis of XML encoded

messages

• message exchange on the basis of

Internet protocols

Independence and Integration

through ...

• SOAP

– XML standard for message encoding

– independent of transport protocol

– independent of client and server implementations: Java, .NET,

Python, …

• Web Services Description Language - WSDL (1.1)

– Interface description in XML

• Communication on the basis of existing protocols and

server architectures

– HTTP and Web server

– SMTP and mail server

– FTP and FTP server

• Standardisation (W3C)

– SOAP 1.2, WSDL 1.1 (1.2 und 2.0)

– additional protocols based on SOAP and WSDL

– protocol bindings (HTTP)

Web Services Scenario



SOAP Web SOAP Web

script client HTTP

HTTP Service A Service B





SOAP

IIS (.NET web service container)

Java client HTTP SOAP

SMTP

Web

SOAP Web- SOAP

.NET client SMTP

Service

HTTP Service C

D

web server + Java

SOAP e-mail server +

... client protocol X

web service

container SOAP processor



SOAP remote

protocol procedure call

Pros and Cons

• Pros

– independent of programming language, run

time environment and operating system

– Built on existing Internet infrastructure

– standardized

– promoted from important players (Microsoft,

IBM, SAP, Sun)



• Cons

– performance (XML)

Web Service Infrastructure

Discover Services

What services do exist?

Where are they? (URL)



E.g.: UDDI,

DISCO

client(s) Service Description (in WSDL)

What message does the service

know and how are those called?





Service Calls

Using services via

SOAP, HTTP, XML-RPC, ... Web Service

+ container

Universal, Description, Discovery

and Integration (UDDI)

URL: http://www.uddi.org

• Standardized protocol for searching for and using web

services

• Provides web services interface

2.) search 1.) register

Directory

(UDDI)





Web

3.) connect Service A

Client 4.) call

Web

Service B

Web Service Architecture (1)

Discovery service



WSD1 URL1

WSD2 URL2



... ...









pu

h

rc









bli

a









sh

se









Web service

container



Client inquiry

Web

Service

call

Web Service Architecture (2)

Discovery service



WSD1 URI1

WSD2 URI2



... ...









pu

h

rc









bli

a









sh

se









service inquiry (URI) service inquiry



service description (WSD)

Web service service description (WSD) Web

Client

container service

service call (SOAP)

service call





result: SOAP result

Web Services

Introduction

Web Services in .NET

SOAP

Service Description with WSDL

Preview of Web Services .NET 2.0

Summary

Web Services in .NET

• IIS and ASP.NET infrastructure support web services

• .NET Framework provides several

– base classes

– attributes

– protocols

for the realization of web services

• Visual Studio.NET provides powerful tools for

developing web services

– implementation

– testing

– administration of IIS

– generation of proxy code (wsdl.exe)

.NET Namespaces

• System.Web.Services

– for developing web services (e.g.:

WebService, WebMethod)

• System.Web.Services.Configuration

– for extending SOAP

• System.Web.Services.Description

– for creating and manipulating WSDL

descriptions

• System.Web.Services.Protocols

– for implementation of communication

protocols (e.g. SOAP-HTTP)

• System.Xml.Serialization

– for XML serialization

Implementation of Web Services





deriving a class from base class System.Web.Services.WebService

public class MyWebService : WebService {





Identification and settings by .NET attributes

identification of web service methods

definition of format and encoding

XML namespaces and element names to use

etc.





[WebMethod(Description= “comment ")]

[…]

public Returntype MyWebMethod( …) {



Building a Web Service

 Open File -> New -> select ASP.NET

Web Services

 Define a class that inherits from

System.Web.Services.WebService

 VS .NET creates a skeleton webservice

Using System.Web;

Using System.Web.Services;

Using System.Web.Services.Protocols;

Public class Service : System.Web.Services.WebService {

[WebMethod]

Public string Helloworld()

{

return “Hello World”;

}}

Web Service Program – Example1

Viewing Web Service page

Testing Add ( ) Web Service

Method

Result of Add() Method (in XML)

Web Services

Introduction

Web Services in .NET

SOAP

Service Description with WSDL

Preview of Web Services .NET 2.0

Summary

SOAP

• Simple message protocol in XML

– for packaging arbitrary application data

– single messages only („one-way“)

– asynchronous

• Independent of transport protocol



• SOAP does not define:

– distributed object model

– communication protocol

– distributed garbage collection

– distributed events (distributed callbacks)

Application of SOAP

• SOAP is extendable

– method call protocol (RPC)

– security

– authentication

– etc.

• Protocol realisation by combination of messages

(message exchange patterns)

– one-way, request-response, multicast, …

e.g.: request-response for RPC by 2 messages



1: GetTime_Request

Client 2: GetTime_Response Server

SOAP Messages

SOAP messages comparable to letters with

• envelope ()

as container







Message Header • letter head ()

Message Header with meta information

(Message Headers)





Data

• letter ()



with arbitrary XML data

Fault Descriptions



• fault descriptions

()

A SOAP Message

SOAP Message The complete SOAP Message

Standard Protocol (HTTP, SMTP, etc.)

Protocol Headers and SOAP Headers



SOAP Envelope encloses payload



SOAP Header



Headers Individual headers



contains SOAP

SOAP Body

Message Name and Data

XML Encoded SOAP

Message Name & Data

Message Name and Data

Web Services

Introduction

Web Services in .NET

SOAP

Service Description with WSDL

Preview of Web Services .NET 2.0

Summary

Web Service Description Language (WSDL)



• WSDL is an XML based IDL for web services

• a WSD describes:

– used data types

– structure of messages

– operations (methods)

– protocols to call operations

– addresses of web service





current version in .NET: WSDL 1.1

(http://schemas.xmlsoap.org/wsdl/)

Structure of WSDL 1.1

WSDL description of a web services

types defined in



simple messages

parts of messages

abstract



part

interface specification

operations of an interface

input message

output message





binding of interface to protocols and encoding

description of the binding for each operation



service description concrete

URI and binding to port part





WSDL for TimeService (1)

• WSDL description created by web container

(IIS) http://localhost/WebProject1/TimeService.asmx?WSDL





abstract

part





















WSDL for TimeService (2)





















concrete

part







Simple web service for querying the time











Creating Proxy

Proxy

• To represent the server on the client

• To bundle client requests into SOAP messages that are

sent to server

• To retrieve the responses

• Creating Proxy

• Enter wsdl @ VS Command-line prompt, followed by

path to WSDL

wsdl http://localhost/WebProject1/TimeService.asmx?wsdl

• Creates a C# proxy file with complex code produced by

WSDL tool to build the proxy DLL (needed to build your

client)

Proxy – Code

• Declare a class that derives from

SoapHttpClientProtocol class

Ex: Public class service1 :

System.Web.Services.Protocols.SoapHttpClientProtocol

• Constructor sets the URL Property to the

URL of .asmx page

Ex: Public Service1 ( ) { this.Url =

“http://localhost:19975/WebServiceExample/Service.asmx”;}

Creates Proxy file named Service1.cs



• Provides Asynchronous support for your

methods.

Ex: for Add ( ) method, it also creates BeginAdd ( ), EndAdd ( ), …

Testing the Web Service

• Create simple C# application. Right-click project

& add Service1.cs

• Example

Web Services

Introduction

Web Services in .NET

SOAP

Service Description with WSDL

Preview of Web Services .NET 2.0

Summary

Indigo

• Web services in .NET 2.0 are integrated in

Indigo

• Indigo unites

– .NET remoting

– Web services

– .NET Enterprise Services

in one uniform programming model

• Indigo provides

– reliable communication

– secure communication and authentication

– host independence

– message-based server activation

Indigo Architecture

service



message flow

typed channel



untyped channel



port





formatter





transport





to destination

Web Services

Introduction

Web Services in .NET

SOAP

Service Description with WSDL

Preview of Web Services .NET 2.0

Summary

Summary

• Web services are a middleware technology

• on the basis of XML and Internet protocols

• independent of programming language and run

time system

• for the integration of heterogeneous, distributed

systems

• .NET supports web services

– development of web services

– development of web service clients

• In .NET 2.0 Indigo unites the different remoting

technologies



Related docs
Other docs by xumiaomaio
Education and Outreach
Views: 0  |  Downloads: 0
SuggestedReadCodeListsforTemplates0809v0_05
Views: 0  |  Downloads: 0
MODULE 01 NOTES
Views: 0  |  Downloads: 0
Download
Views: 4  |  Downloads: 0
Pinemont Zine - May 2010.pub
Views: 0  |  Downloads: 0
08_18_09_regmtgag
Views: 0  |  Downloads: 0
educator-instructional-presentation
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!