電腦網路實驗

Download Report

Transcript 電腦網路實驗

WEB SERVICES
Lab 223
潘建廷 [email protected]
何偉聖 [email protected]
OUTLINE

6/1
Web service
 HTTP
 Apache (server)
 MySQL (database)


6/8
HTML5
 PHP

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

WHAT ARE WEB SERVICES?

Web services are application components

Web services communicate using open protocols

Web services are self-contained and selfdescribing

Web services can be discovered using UDDI

Web services can be used by other applications

XML+HTTP is the basis for Web services
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.
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
WEB SERVICES ARCHITECTURE (1)
WEB SERVICES ARCHITECTURE (2)

Web Services have three basic platform elements:
SOAP
 WSDL
 UDDI

SOAP TOOLS : Microsoft soaptoolkit30
SOAP
(SIMPLE OBJECT ACCESS PROTOCOL)
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
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的方式。
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
UDDI
(UNIVERSAL DESCRIPTION, DISCOVERY, AND INTEGRATION)
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
DISCOVER SERVICE (1)
--- WEBSERVICE EXPLORER
DISCOVER SERVICE (2) ---FROM INTERNET

http://www.xmethods.net/ve2/index.po
EX.1-1

Goal : query the price of products
the product ID
EX.1-2
Client 端程式
EX.1-3
回傳結果
EX.2-1

Goal: find the web services by web service
EX.2-2
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檔
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 networkcore devices
Network-core devices do
not run user applications
 Applications on end
systems allows for rapid
app development,
propagation

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

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
APP-LAYER PROTOCOL DEFINES

Types of messages
exchanged,


what fields in
messages & how fields
are delineated
Message semantics


e.g., request, response
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

Message syntax




Proprietary protocols

e.g., Skype
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
some apps (e.g.,
multimedia) require
minimum amount of
throughput to be
“effective”
 other apps (“elastic
apps”) make use of
whatever throughput
they get

Timing

some apps (e.g.,
Internet telephony,
interactive games)
require low delay to be
“effective”
Throughput

Security

Encryption, data
integrity, …
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.p
hp
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
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
HTTP REQUEST MESSAGE

Two types of HTTP messages:


request, response
HTTP request message:

ASCII (human-readable format)
HTTP REQUEST MESSAGE: GENERAL
FORMAT
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

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

HTTP RESPONSE MESSAGE
HTTP RESPONSE STATUS CODES


In first line in server->client response message.
A few sample codes:

200 OK


301 Moved Permanently


request message not understood by server
404 Not Found


requested object moved, new location specified later in this
message (Location:)
400 Bad Request


request succeeded, requested object later in this message
requested document not found on this server
505 HTTP Version Not Supported
實驗
實驗步驟50%
 問題討論40%
 心得感想10%

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


HTML Documents = Web Pages
HTML documents describe web pages
 HTML documents contain HTML tags and plain text
 HTML documents are also called web pages

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
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"

REFERENCE
HTML/CSS/JavaScript
http://www.w3schools.com/
 PHP http://www.wasite.com/php0/
 SQL http://www.1keydata.com/tw/sql/sql.html
