1. Trang chủ
  2. » Công Nghệ Thông Tin

slike bài giảng môn công nghệ web services

46 1,8K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 46
Dung lượng 3,95 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Nền tảng của web service Kiến trúc của web service Mô hình của ứng dụng với Web service... Là một tập các phương thức được gọi thực hiện từ xa thông qua một địa chỉ URL Là một tập các ph

Trang 1

Chuyên đề Thương mại điện tử

Công nghệ Web services

Tháng 11-2006 Khoa Công nghệ thông tin

Bộ môn HTTT

Trang 3

Các ứng dụng phân tán

Distributed Application

Máy tính

Máy tính

Dữ liệu

Ứng dụng phân tánỨng dụngphân tán

Dữ liệu

Trang 4

Service Broker

Trang 5

Web Service

Web Service là gì ?

Nền tảng của web service

Kiến trúc của web service

Mô hình của ứng dụng với Web service

Trang 6

Là một tập các phương thức được gọi thực hiện

từ xa thông qua một địa chỉ URL

Là một tập các phương thức được gọi thực hiện

từ xa thông qua một địa chỉ URL

1

Sử dụng để tạo các ứng dụng phân tán

Sử dụng để tạo các ứng dụng phân tán

2

Trang 8

Web Service Provider

UDDI (Web Service Broker) UDDI (Web

Service Broker)

Web Service Consumer

Web Service Consumer

Trang 9

Kiến trúc của Web Service

UDDI

Any Client

SOAP IIS

Web Service

Trang 10

Cung cấp đúng service mà consumer yêu cầu

Trang 11

Web service consumer

Trang 12

Là môi giới giữa consumer và provider

1

Tương tác với provider : để lấy các thông tin về web service

Tương tác với provider : để lấy các thông tin về web service 2

Tương tác với consumer :cung cấp cho consumer địa chỉ các Web service

Tương tác với consumer : cung cấp cho consumer địa chỉ các Web service

Trang 13

Mô hình tương tác giữa các thành phần

2

1

5

Web service developer builds and deploys a pricing Web service

Web service developer builds and deploys a pricing Web service 1

Web service developer registers and categorizes the Web service

Web service developer registers and categorizes the Web service 2

Web service consumer queries UDDI for “pricing” services

Web service consumer queries UDDI for “pricing” services

Web service developer builds a solution that directly

consumes the Web service data

Web service developer builds a solution that directly

consumes the Web service data

5

Pricing Web Service

4

Trang 14

HTTP

Trang 15

HTTP – Hyper text transfer protocol

POST /TheStockExchange/Trading/GetStockPrice.asp HTTP/1.1 Host: localhost

Content-Type: application/x-www-form-urlencoded Content-Length: 11

Symbol=MSFT

POST /TheStockExchange/Trading/GetStockPrice.asp HTTP/1.1

Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 11

Symbol=MSFT HTTP Request

HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 75

Trang 16

XML – Extend Markup Language

Sử dụng để mô tả Web service interface

Trang 19

SOAP(3) - Message Structure

<Header> encloses headers

<Envelope> encloses payload

Protocol binding headers The complete SOAP message

Trang 20

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

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

</m:GetLastTradePrice>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Trang 21

SOAP(5) - Example of a SOAP Response

</m:GetLastTradePriceResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Trang 22

Lập trình Web service bằng VS.NET 2003

Web service programming - provider side

1

Web service programming - consumer side

2

Trang 23

System System.Data System.Web System.Web.Webservices System.Xml

Các thành phần

3

File *.asmx File global.asax File web.config Thư mục Bin

File *.asmx File global.asax File web.config Thư mục Bin

Trang 24

Thêm chỉ thị [Web Method]

Thêm chỉ thị [Web Method]

Trang 25

Lập trình Web service (3)

BufferResponse CacheDuration Description EnableSession TransactionOption

Các thuộc tính của [WebMethod]

Các thuộc tính của [WebMethod]

5

Trang 26

[WebMethod (Description=“This method using for

Trang 27

XmlElement XmlAttribute XmlRoot

Namespace : System.Xml.Serialization Namespace : System.Xml.Serialization

Trang 28

<type>C</type>

<account>

<account status=“123”>

<description>Hello</description> <number>10 </number>

<type>C</type>

<account>

Trang 29

[return: XmlArray (" AccountList ")]

[return: XmlArrayItem (" Account ")]

public Acct[] GetAllAccounts()

<AccountList> <account> ………

<account> <account> ….

</account>

<AccountList>

<AccountList> <account> ………

<account> <account> ….

</account>

<AccountList>

Ví dụ 2

Trang 30

public Acct[] GetAllAccounts()

{

[return: XmlArrayItem (ElementName="savingsAcct", Type=typeof(SavingsAcct))]

[return: XmlArrayItem (ElementName="creditCardAcct", Type=typeof(CreditCardAcct))] [WebMethod]

public Acct[] GetAllAccounts()

Trang 31

Lập trình Web service (8)

Input and output parameter (in, ref,…)

Variable length parameter list (homogeneous,

heterogeneous )

Variable length parameter list (homogeneous,

heterogeneous )

Simple data types

Kiểu dữ liệu trong web service method

6

Classes and structures Array, Collections

DataSets DataSets Complex data type

Trang 32

Sử dụng : XmlInclude Name space System.Xml.Serialization

Trang 33

Lập trình Web service – provider side(10)

Ví dụ

public class Acct

{

public string Description;

public string Number;

public string Type;

public decimal Balance;

public string Status;

public string Description;

public string Number;

public string Type;

public decimal Balance;

public string Status;

[return:XmlArrayItem("Account")] public Acct[] GetAllAccounts() {

SavingsAcct a = new SavingsAcct(); CreditCardAcct cc = new

[return: XmlArrayItem ("Account")]

public Acct [] GetAllAccounts () {

SavingsAcct a = new SavingsAcct(); CreditCardAcct cc = new

Trang 34

Triển khai Web service

Web Service Files Needed Remov e .sln, vbproj, csproj,

.vsdisco, webinfo resx

.vb, cs xsd

\Web References folder and files

\bin directory and dll(s) asmx

Web.config Global.asax xml

Tạo 1 web setup

project trong VS.NET

Sử dụng Windows

Installer Files

Tạo 1 web setup

project trong VS.NET

2

Trang 35

Web Service Consumer

Trang 38

Sử dụng Web service trong NET

Tạo lớp proxy để giao tiếp với web service

Gọi bình thường như các phương thức khác

Gọi bình thường như các phương thức khác

Add Web References …

wsdl [options] {URL | Path}

wsdl http://www.woodgrovebank.com/services/bank.asmx?wsdl wsdl http://www.woodgrovebank.com/services/bank.asmx?wsdl

Trang 39

WSDL Document

Trang 41

SOAP Request and Response

Trang 43

Web service and State Management

ASP.NET Web service Application  Web Applicaton

Trang 44

Ứng dụng của Web Services

WS là một tập hợp các chức năng được thực thi qua môi trường mạng, được các ứng dụng khác sử dụng

WS là một tập hợp các chức năng được thực thi qua môi trường mạng, được các ứng dụng khác sử dụng

Trang 45

Demo

Ngày đăng: 23/10/2014, 17:23

TỪ KHÓA LIÊN QUAN

w