42
WEB SERVICES Lab 223 潘潘潘 [email protected] 潘潘潘 [email protected]

WEB SERVICES Lab 223 潘建廷 [email protected] 何偉聖 [email protected]

Embed Size (px)

Citation preview

Page 1: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WEB SERVICESLab 223

潘建廷 [email protected]

何偉聖 [email protected]

Page 2: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

OUTLINE

6/1 Web service HTTP Apache (server) MySQL (database)

6/8 HTML5 PHP

Page 3: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHY WEB SERVICES?

Interoperability has Highest Priority

Web Services take Web-applications to the Next Level

Web Services have Two Types of Uses Reusable application-components Connect existing software

Page 4: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHAT ARE WEB SERVICES? Web services are application components

Web services communicate using open protocols

Web services are self-contained and self-describing

Web services can be discovered using UDDI

Web services can be used by other applications

XML+HTTP is the basis for Web services

Page 5: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

THE DIFFERENCE BETWEEN XML AND HTML

XML is not a replacement for HTML.

XML and HTML were designed with different goals: XML was designed to transport and store data,

with focus on what data is HTML was designed to display data, with focus

on how data looks

HTML is about displaying information, while XML is about carrying information.

Page 6: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHAT IS XML ? XML stands for EXtensible Markup Language

XML is a markup language much like HTML

XML was designed to carry data, not to display data

XML tags are not predefined. You must define your own tags

XML is designed to be self-descriptive

XML is a W3C Recommendation

Page 7: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WEB SERVICES ARCHITECTURE (1)

Page 8: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WEB SERVICES ARCHITECTURE (2)

Web Services have three basic platform elements: SOAP WSDL UDDI

Page 9: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

SOAP(SIMPLE OBJECT ACCESS PROTOCOL)

SOAP TOOLS : Microsoft soaptoolkit30

Page 10: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHAT IS SOAP(SIMPLE OBJECT ACCESS PROTOCOL)?

SOAP is an XML-based protocol to let applications exchange information over HTTP.

Or more simple: SOAP is a protocol for accessing a Web Service. SOAP stands for Simple Object Access Protocol SOAP is a communication protocol SOAP is a format for sending messages SOAP is designed to communicate via Internet SOAP is platform independent SOAP is language independent SOAP is based on XML SOAP is simple and extensible SOAP allows you to get around firewalls SOAP is a W3C standard

Page 11: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WSDL(WEB SERVICES DESCRIPTION LANGUAGE)

• 附檔名為 .WSDL, 主要的用途是”描述 Web Service”• 使用共同的標準 , 以便和各種用戶端應用程式相互整合 , 由 IBM 和 Microsoft 共同 研擬

● ( Type ) : 定義各 Element 實際對應之資料型態。● ( Message ) : 定義各輸入、輸出 Message 由哪些參數 Element 所組成。● ( PortType ) : 此 Service 所有 Ports 提供之全部 Operations 的集合。● ( Binding ) : 定義 Binding 所使用的通訊協定,以及提供之 Operations 。

●<service> : 此 WSDL 文件所要描述的 Web Service 集合。 ●<port> : 每一個 Port 代表外界 Client 可以和此 Service 溝通的一個進入點,一個 Port 會指定一個Binding 的方式。

Page 12: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHAT IS WSDL(WEB SERVICES DESCRIPTION LANGUAGE)?

WSDL is an XML-based language for locating and describing Web services. WSDL stands for Web Services Description

Language WSDL is based on XML WSDL is used to describe Web services WSDL is used to locate Web services WSDL is a W3C standard

Page 13: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

UDDI(UNIVERSAL DESCRIPTION, DISCOVERY, AND INTEGRATION)

Page 14: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHAT IS UDDI(UNIVERSAL DESCRIPTION, DISCOVERY, AND INTEGRATION)?

UDDI is a directory service where companies can register and search for Web services. UDDI stands for Universal Description, Discovery

and Integration UDDI is a directory for storing information about

web services UDDI is a directory of web service interfaces

described by WSDL UDDI communicates via SOAP UDDI is built into the Microsoft .NET platform

Page 15: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

DISCOVER SERVICE (1) --- WEBSERVICE EXPLORER

Page 16: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

DISCOVER SERVICE (2) ---FROM INTERNET

http://www.xmethods.net/ve2/index.po

Page 17: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

EX.1-1

Goal : query the price of products

the product ID

Page 18: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

EX.1-2

Client 端程式

Page 19: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

EX.1-3

回傳結果

Page 20: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

EX.2-1

Goal: find the web services by web service

Page 21: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

EX.2-2

Page 22: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

EX.3

一 : 公司或個人的資訊查詢提供Zip Code Information 查詢美國的郵遞區號Delayed Stock Quote 查詢延遲 20 秒的即時股價Barnes and Noble Price Quote 書本的 ISBN 跟價格查詢California Traffic Conditions 即時的美國高速公路交通狀況

二 : 資料檔案的分散存取及服務XMethods Filesystem 提供 1M 的檔案自由存取空間FTP Service FTP 服務SMTP Server Mail 的 SMTP 服務

三 : 數據遠端分散運算Currency Exchange Rate 兩種匯率的換算MillionaireQuiz 心理測驗 –你是百萬富翁嗎 ? ( 支援行動電話 )

LogFileParser 遠端分析你的 IIS 伺服器的 log 檔

Page 23: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

CREATING A NETWORK APP Write programs that

Run on (different) end systems

Communicate over network

e.g., web server software communicates with browser software

No need to write software for network-core devices Network-core devices

do not run user applications

Applications on end systems allows for rapid app development, propagation

Page 24: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

CLIENT-SERVER ARCHITECTURE

server Always-on host Permanent IP address Server farms for scaling

clients Communicate with

server May be intermittently

connected May have dynamic IP

addresses Do not communicate

directly with each other

Page 25: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

NETWORK APPLICATION

Some network apps E-mail Web Instant messaging Remote login P2P file sharing Multi-user network games Streaming stored video clips Voice over IP Real-time video conferencing Grid computing Cloud computing

Page 26: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

APP-LAYER PROTOCOL DEFINES Types of messages

exchanged, e.g., request, response

Message syntax what fields in

messages & how fields are delineated

Message semantics meaning of

information in fields Rules for when and

how processes send & respond to messages

Public-domain protocols defined in RFCs allows for

interoperability e.g., HTTP, SMTP

Proprietary protocols e.g., Skype

Page 27: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WHAT TRANSPORT SERVICE DOES AN APP NEED? Data loss

some apps (e.g., audio) can tolerate some loss

other apps (e.g., file transfer, telnet) require 100% reliable data transfer

Timing some apps (e.g.,

Internet telephony, interactive games) require low delay to be “effective”

Throughput some apps (e.g.,

multimedia) require minimum amount of throughput to be “effective”

other apps (“elastic apps”) make use of whatever throughput they get

Security Encryption, data

integrity, …

Page 28: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

WEB AND HTTP

Web page consists of objects Object can be HTML file, JPEG image, Java

applet, audio file,… Web page consists of base HTML-file which

includes several referenced objects Each object is addressable by a URL Example URL:

http://www.ccu.edu.tw/layer2/user_current_student.php

Page 29: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTTP OVERVIEW

HTTP: hypertext transfer protocol Web’s application layer

protocol client/server model Client

browser that requests, receives, “displays” Web objects

Server Web server sends objects

in response to requests

Page 30: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTTP OVERVIEW (CONTINUED)

Uses TCP client initiates TCP

connection (creates socket) to server, port 80

server accepts TCP connection from client

HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)

TCP connection closed

HTTP is “stateless” server maintains no

information about past client requests

Page 31: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTTP REQUEST MESSAGE

Two types of HTTP messages: request, response

HTTP request message: ASCII (human-readable format)

Page 32: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTTP REQUEST MESSAGE: GENERAL FORMAT

Page 33: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

UPLOADING FORM INPUT

URL method Uses GET method Input is uploaded in URL field of request line: http://translate.google.com.tw/?hl=zh-

TW&tab=wT#

Post method Web page often includes form input Input is uploaded to server in entity body

Page 34: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

METHOD TYPES

HTTP/1.0 GET POST HEAD

asks server to leave requested object out of response

HTTP/1.1 GET, POST, HEAD PUT

uploads file in entity body to path specified in URL field

DELETE deletes file specified

in the URLfield TRACE CONNECT OPTIONS

Page 35: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTTP RESPONSE MESSAGE

Page 36: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTTP RESPONSE STATUS CODES

In first line in server->client response message.

A few sample codes: 200 OK

request succeeded, requested object later in this message

301 Moved Permanently requested object moved, new location specified later in

this message (Location:) 400 Bad Request

request message not understood by server 404 Not Found

requested document not found on this server 505 HTTP Version Not Supported

Page 37: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

實驗 實驗步驟 50% 問題討論 40% 心得感想 10%

Page 38: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTML

What is HTML? HTML is a language for

describing web pages. HTML stands for Hyper

Text Markup Language HTML is not a

programming language, it is a markup language

A markup language is a set of markup tags

HTML uses markup tags to describe web pages

HTML Tags HTML tags are

keywords surrounded by angle brackets like <html>

HTML tags normally come in pairs like <b> and </b>

The first tag in a pair is the start tag, the second tag is the end tag

Page 39: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

HTML Documents = Web Pages HTML documents describe web pages HTML documents contain HTML tags and plain

text HTML documents are also called web pages

Page 40: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

JAVASCRIPT

What is JavaScript? JavaScript was designed to add interactivity to

HTML pages JavaScript is a scripting language A scripting language is a lightweight

programming language JavaScript is usually embedded directly into

HTML pages JavaScript is an interpreted language (means

that scripts execute without preliminary compilation)

Everyone can use JavaScript without purchasing a license

Page 41: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

PHP

What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many databases PHP is an open source software PHP is free to download and use

What is a PHP File? PHP files can contain text, HTML tags and scripts PHP files are returned to the browser as plain

HTML PHP files have a file extension of ".php", ".php3",

or ".phtml"

Page 42: WEB SERVICES Lab 223 潘建廷 chp32324@hotmail.com 何偉聖 administratorEx@hotmail.com

REFERENCE

HTML/CSS/JavaScript http://www.w3schools.com/

PHP http://www.wasite.com/php0/ SQL http://www.1keydata.com/tw/sql/sql.html