Antonius Rachmat C, S.Kom, M.Cs

Teks penuh

(1)

Arsitektur Aplikasi

p

Perangkat Enterprise #10

g

p s # 0

(2)

WWW

“ Today, t he principal use of t he World Wide Web is for int eract ive access t o docum ent s and applicat ions.

I n alm ost all cases, such access is by hum an users,

t ypically w orking t hrough Web brow sers, audio players, or ot her int eract ive front - end syst em s

ot her int eract ive front end syst em s.

The Web can grow significant ly in pow er and scope if it is ext ended t o support com m unicat ion bet w een applicat ions ext ended t o support com m unicat ion bet w een applicat ions, from one program t o anot her.”

(3)

ld

d

b

World Wide Web

t he Web i t he o ld’ l

ge t lient / e

e

‡

t he Web is t he w orld’s largest client / server

syst em

com m unicat ion occurs via m essage passing

com m unicat ion occurs via m essage passing

‡ w it hin brow ser, select URL of desired page ‡ brow ser request s page from server

‡ server responds w it h m essage cont aining ‡ server responds w it h m essage cont aining

ƒ type of page (HTML, gif, pdf, zip, …)

ƒ page contents

‡ brow ser uses t ype info t o correct ly display page ‡ if page cont ains ot her it em s ( im ages, applet s, …) ,

(4)

d

(5)

b S

Now, Web Service…

W b S

i

t

li

t i

‡

W e b Se r vice s ca n con ve r t you r a pplica t ion s

in t o W e b- a pplica t ion s.

„ By using Web services, your applicat ion can publish it s

„ By using Web services, your applicat ion can publish it s funct ion or m essage t o t he rest of t he world.

‡

W e b Se r vice s ca n be u se d by ot h e r

a pplica t ion s

a pplica t ion s.

„ Ex: wit h Web services your account ing depart m ent 's Win 2k servers can connect wit h your I T supplier's UNI X

server.

„ Can be used as API

‡

Th e ba sic W e b Se r vice s pla t for m is X M L +

‡

Th e ba sic W e b Se r vice s pla t for m is X M L +

H TTP.

„ Web services uses XML t o encode and decode your dat a d SOAP ( b d HTTP) t t t it

(6)

Pengertian-pengertian

‡ Ge n e r ic: Any applicat ion accessible t o ot her applicat ions

‡ Ge n e r ic: Any applicat ion accessible t o ot her applicat ions over t he Web

„ Very open definit ion, alm ost any URL becom es a “ Web service” under t his definit ion

under t his definit ion

‡ UD D I con sor t iu m: Web services are self- cont ained, m odular business applicat ions t hat have open, I nt ernet -orient ed, st andards- based int erfaces

„ Bet t er, but st ill not specific enough

‡ W 3 C: A Web service is a soft ware applicat ion ident ified by a URI , whose int erfaces and bindings are capable of being

d fi d d ib d d di d XML A W b i

defined, described, and discovered as XML. A Web service support s direct int eract ions wit h ot her soft ware agent s using XML- based m essages exchanged via I nt ernet - based prot ocols

prot ocols

(7)

Pengertian-pengertian

‡

W ik ipe dia

: According t o t he W3C, a Web service

is a soft w are syst em designed t o support

int eroperable m achine- t o- m achine int eract ion

int eroperable m achine- t o- m achine int eract ion

over a net w ork. I t has an int erface t hat is

described in a m achine- processable form at such

p

as WSDL. Soft w are applicat ions w rit t en in various

program m ing languages and running on various

l

f

b

i

h

d

plat form s can use web services t o exchange dat a

over com put er net w orks like t he I nt ernet in a

m anner sim ilar t o int er- process com m unicat ion

m anner sim ilar t o int er- process com m unicat ion

on a single com put er.

(8)

S

l

WS Example

‡

ht t p: / / www.google.com / apis/

‡

ht t p: / / t erraserver.m icrosoft .net / TerraServ

p

ice.asm x

‡

ht t p: / / www.xm et hods.net

‡

ht t p: / / www.xm et hods.net

‡

ht t p: / / soap.am azon.com / schem as2/ Am az

onWebServices wsdl

onWebServices.wsdl

(9)

E

l A G

l Cli

Example: A Google Client

‡ Creat e a local proxy class, inst ant iat e, and invoke

‡ The proxy class MyService generat ed from a WSDL file, an XML-encoded service descript ion

encoded service descript ion

Dim MyLicenseKey As St ring ' Variable t o St ore t he License Key ' Declare variable for t he Google search service

Di M S i A l i G l S hS i N

Dim MyService As com .google.api.GoogleSearchService = New _ com .google.api.GoogleSearchService

' Declare variable for t he Google Search Result

Dim MyResult As com .google.api.GoogleSearchResulty esu t s co goog e ap Goog eSea c esu t ' Please Type your license key here

MyLicenseKey = " t GCTJkYos3YI t LYzI 9Hg5quBRY8bGqiM" ' Execut e Google search on t he t ext ent er and license key M R lt M S i d G l S h( M Li K

MyResult = MyService.doGoogleSearch( MyLicenseKey, _ Text Box1.Text , 0, 1, False, " " , False, " " , " " , " " ) ' out put t he t ot al Result s found

Label2.Text = " Tot al Found : " & _

(10)

l

A h

doGoogleSearch(myKey, q) …

(11)

C

h

b

(12)
(13)

Web Service

M

t k

k

d t d l

f

t XML

‡

Mem pert ukarkan dat a dalam form at XML.

‡

Tersedia dan dikom unikasikan m elalui I nt ernet

at au int ranet

at au int ranet .

‡

Bersifat operat ing syst em / program m ing language

independent .

p

‡ Berupa web applicat ion yang t idak m em iliki web int erface. ‡

Web service m em pert ukarkan dat a ant ara service

request or ( aplikasi yang m enggunakan

request or ( aplikasi yang m enggunakan

dat a/ service) dan service provider ( server

penyedia dat a/ service) m enggunakan service

p

y

/

)

gg

regist ry ( yang berisi kum pulan service- service) ,

dengan salah sat u t eknologi:

„ XML RPC

„ XML- RPC

(14)

b S

Web Service

‡

Web service berbeda dengan m odel aplikasi

‡

Web service berbeda dengan m odel aplikasi

t erdist ribusi t radisional sepert i CORBA dan RMI

dim ana m et hod yang dipanggil dieksekusi m elalui

j

i

d

h

ilk

lt

b

l

j aringan dan m enghasilkan

r e su lt

berupa

va lu e

m et hod t ersebut , sedangkan web service

m enyediakan m et hod yang akan m enghasilkan

lt

b

d t XM L

( b k

d t bi

)

r e su lt

berupa

da t a XM L

( bukan dat a biner)

‡

Web service dapat dipanggil/ digunakan m elalui

w eb, aplikasi deskt op, at aupun aplikasi m obile

w eb, aplikasi deskt op, at aupun aplikasi m obile

‡

Kelebihan:

„ I nt eroperabilit y ( plat form dan aplikasi)

Dapat m em publikasikan service dan m et hod sehingga

„ Dapat m em publikasikan service dan m et hod sehingga m udah digunakan

(15)
(16)

b

b

Website vs Web service

‡

Mem iliki w eb int erface

‡

Dibuat unt uk berint eraksi langsung dengan user

‡

Dibuat unt uk bekerj a pada w eb brow ser

‡

Bersifat front - end

(17)

b

b S

Website vs Web Service

Tid k iliki i f b ik

‡ Tidak m em iliki int erface yang baik

‡ Dibuat unt uk berint eraksi langsung dengan applikasi yang lain, baik berbeda OS sekalipun, bukan dengan user.a , ba be beda OS se a pu , bu a de ga use

‡ Dibuat unt uk bekerj a pada sem ua t ipe client applikasi / perangkat device

B if t b hi d t h

‡ Bersifat behind t he scene.

(18)

TT

h d

HTTP Methods

‡

GET ( ret rieve a resource)

‡

HEAD ( ret rieve m et adat a about a

(

resource)

‡

POST ( add inform at ion t o a resource)

‡

POST ( add inform at ion t o a resource)

‡

PUT ( creat e a new resource / upload)

‡

DELETE ( delet e an exist ing resource)

(19)

b A

WebDAV

‡ W e b- ba se d D ist r ibu t e d Au t h or in g a n d V e r sion in g is a

‡ W e b- ba se d D ist r ibu t e d Au t h or in g a n d V e r sion in g is a set of ext ensions t o t he Hypert ext Transfer Prot ocol ( HTTP) which allows users t o collaborat ively edit and m anage files on rem ot e World Wide Web servers

on rem ot e World Wide Web servers

‡ The prot ocol facilit at es " I nt ercreat ivit y" , m aking t he Web a readable and writ able m edium

‡ The original vision of t he Web as expounded by Tim

‡ The original vision of t he Web as expounded by Tim

Berners- Lee was a bot h readable and writ able m edium .

(20)

b A

WebDAV

PROPFI ND U d t t i t i t d XML

‡ PROPFI ND — Used t o ret rieve propert ies, st ored as XML, from a resource. I t is also overloaded t o allow one t o

ret rieve t he collect ion st ruct ure ( a.k.a. direct ory hierarchy) of a rem ot e syst em support s bot h shared and exclusive locks.

‡ UNLOCK To rem ove a lock from a resource

(21)

b A

l

WebDAV alternatives

‡

CMS ( Cont ent Managem ent Syst em )

‡

FTP wit h CVS ( Cont rol Versioning Syst em )

(

g

y

)

/ SVN ( Subversion)

‡

SMB Prot ocol ( Sam ba and Windows)

‡

SMB Prot ocol ( Sam ba and Windows)

‡

Wiki Syst em

‡

Web Service

(22)

k

b S

Back: Web Service properties

W b i h ” lf d ibi ” j ik kit b t

‡ Web service harus ”se lf- de scr ibin g” : j ika kit a m em buat web service, kit a harus j uga m em publikasikan public

int erface yang dapat dim engert i dan dipakai.

Mi i l i h iliki h d bl

„ Minim alnya, service harus m em iliki h u m a n - r e a da ble docu m e n t a t ion sehingga developer lain dapat

m engint egrasikan aplikasinya dengan w eb service yang kit a buat

buat .

„ Kit a w aj ib m em buat pu blic in t e r fa ce sehingga dapat

digunakan unt uk m engident ifikasikan sem ua m et hod yang public, argum en- argum ennya dan j uga ret urn valuenya.

p , g g y j g y

‡ Web service harus ”discove r a ble ”: j ika kit a m em buat w eb service, harus ada m ekanism e sederhana agar service dan public m et hod yang kit a buat dapat dikenal dan dit em ukan

p y g p

(23)

WS Layer

‡

XML m essaging dan encoding/ decoding

„

Bagian ini bert anggung j aw ab unt uk

Bagian ini bert anggung j aw ab unt uk

m e n ge n code / m e n de code m e ssa ge

dalam

form at XML sehingga m essage dapat

dim engert i dan dipert ukarkan

dim engert i dan dipert ukarkan.

„

Prot okol/ Service I nt eract ion yang ada di

(24)

WS Layer

WS Layer

S

i

d

i t i

‡

Service descript ion

„ Bagian ini bert anggung j awab unt uk m e n de sk r ipsik a n

pu blic in t e r fa ce sesuai dengan web service yang

p g y g

spesifik.

„ Bagian ini dihandle m elalui Service Descript ion: Web Service Descript ion Language ( WSDL) dan XML Schem ap g g ( ) ‡

Service discovery

„ Bagian ini bert anggung j awab unt uk m e n gu m pu lk a n

(25)

TT G T d

ST

HTTP GET dan POST

GET t

b

t

il i

‡

GET: param et er besert a nilai yang

dikirim kan ke server m erupakan bagian

dari URL yang panj angnya t erbat as

dari URL yang panj angnya t erbat as

(26)

G T

Batas GET

‡

I E: 2.083 charact ers

‡

Firefox: 65.536 charact ers

‡

Safari: 80.000 charact ers

‡

Opera: 190 000 charact ers

‡

Opera: 190.000 charact ers

‡

Apache: 4.000 charact ers

‡

I I S: 16.384 charact ers

‡

Recom m ended: Maks 2.000

‡

Error: 413 Ent it y Too Large

(27)

TT G T d

ST

HTTP GET dan POST

‡

Disim pan di c: \ apache\ ht docs dengan

nam a cobaget .php

(28)
(29)

TT G T d

ST

HTTP GET dan POST

‡

POST: param et er dan nilai yang dikirim kan ke

server adalah m erupakan bagian dari m essage

body dokum en karena it u ukurannya j auh lebih

body dokum en, karena it u ukurannya j auh lebih

besar ( def: 2MB ) . Biasanya digunakan dalam

sebuah form .

(30)
(31)

d

b S

(32)
(33)

Service Requestor (Client)

Service Requestor (Client)

‡ M e n gide n t ifik a si da n m e n e m u k a n se r vice yang relevan sesuai

‡ M e n gide n t ifik a si da n m e n e m u k a n se r vice yang relevan sesuai dengan aplikasi yang ada. Biasanya dilakukan dengan pencarian

t erhadap UD D I Business Direct ory yang berisi service- service yang ada.

‡ Set elah m endapat kan service yang diinginkan, langkah selanj ut nya adalah m e n ca r i se r vice de scr ipt ion. Bisa berupa WSDL at aupu XML-RPC inst ruct ion

‡ M e m bu a t clie n t a pplica t ion. Kit a dapat m em buat XML- RPC at au SOAP client sesuai dengan bahasa pem rogram an yang kit a sukai. Jika SOAP client sesuai dengan bahasa pem rogram an yang kit a sukai. Jika service ini m em iliki file WSDL, kit a j uga m em iliki opsi unt uk secara

ot om at is m em buat program client m enggunakan WSDL invocat ion t ool.

‡ Ja la n k a n clie n t a pplica t ion yang kit a buat dan in vok e t he web i

(34)

Service Provider (Server)

Service Provider (Server)

‡ Kem bangkan fu n gsi fu n gsi u t a m a dari service Biasanya ini

‡ Kem bangkan fu n gsi- fu n gsi u t a m a dari service. Biasanya ini

m erupakan bagian yang paling sulit , sepert i m isalnya koneksi dat abase, EJB, COM, dan lain- lain

‡ Kem bangkan sebuah se r vice w r a ppe r unt uk fungsi- fungsi ut am a t ersebut dalam bent uk XML- RPC at au SOAP service

t ersebut dalam bent uk XML RPC at au SOAP service wrapper/ funct ion/ m et hod.

‡ Kit a harus m enyediakan se r vice de scr ipt ion. Jika kit a m em buat SOAP service kit a harus m em buat file WSDL. Jika kit a m em buat XML- RPC

service, kit a harus m em buat hum an- readable inst ruct ions unt uk service, kit a harus m em buat hum an readable inst ruct ions unt uk int egrasi.

‡ D e ploy t h e se r vice. Kit a dapat m enyesuaikan dengan kebut uhan, apakah diinst al at au berj alan dalam server st andalone at au

diint egrasikan dengan w eb server yang t elah ada. d t eg as a de ga eb se e ya g t e a ada

‡ Kit a harus m e m pu blik a sik a n keberadaan dan spesifikasi service yang t elah kit a buat . Biasanya dapat dilakukan dengan cara

(35)

Service Broker / Service Registry

Service Broker / Service Registry

‡

The service brokers allow service

providers t o publish t heir services

(

r e gist e r , sa ve , a n d ca t e gor iz e

) . They

provide also m echanism s t o locat e

(36)

C

XML-RPC

‡

XML- RPC is an at t em pt t o im plem ent

convent ional Rem ot e Procedure Call ( RPC)

concept s using XML t o t ransm it t he RPC

inform at ion

(37)

C

XML-RPC

‡

Client m enent ukan prosedur dan

param et er yang akan diinvoke ke dalam

XML request , sedangkan server akan

m eresponse

„

ent ah it u fault at au success di dalam XML

response

‡

Dikem bangkan t ahun 1998 oleh UserLand

Soft ware (

(

ht t p: / / www.xm lrpc.com

p

p

)

)

(38)

Request example

< m et hodNam e> exam ples.nam e< / m et hodNam e> < param s>p

(39)
(40)
(41)

l

<Value>

‡

Sem ua t ipe dat a t ersebut harus diapit oleh

(42)
(43)

S

(44)

C

S

XML-RPC Request Structure

S t i

t t

di i XML di

t

‡

Set iap request t erdiri XML, dim ana root

elem ennya adalah <

m e t h odCa ll

> .

S t i

l

<

t h dC ll> t

di i d

i

„

Set iap elem en < m et hodCall> t erdiri dari

elem en < m et hodNam e> yang dapat berisi

elem en < param s> .

p

‡

Elem en <

m e t h odN a m e

> m endefinisikan

nam a prosedur yang dipanggil sem ent ara

p

y

g

p

gg

<

pa r a m s

> berisi daft ar param et er dan

nilainya, set iap param s t erdiri dari

l

l

elem en- elem en <

pa r a m

> yang j uga

(45)
(46)

Here's an example of a response to an

XML-RPC

RPC request:

HTTP/ 1.1 200 OK Connect ion: close Connect ion: close Cont ent - Lengt h: 134

Cont ent - Type: t ext / xm l

D F i 17 J l 1998 19 55 08 GMT Dat e: Fri, 17 Jul 1998 19: 55: 08 GMT Server: UserLand Front ier/ 5.1.2- WinNT

“Luton, LU1 3JU”

< value> < st ring> Lut on, LU1 3JU< / st ring> < / value> < / param >

< / param > < / param s>

(47)
(48)

< ?xm l version= " 1.0" ?>

< nam e> fault Code< / nam e>

< value> < int > 4< / int > < / value> < / m em ber>

< / m em ber> < m em ber>

< nam e> fault St ring< / nam e>

< value> < st ring> Overflow < / st ring> < / value> < / m em ber>

< / st ruct > < / st ruct > < / value> < / fault >

(49)

T

NEXT

Figur

Memperbarui...

Referensi

Memperbarui...

Related subjects : Antonius Rachmat C, S.Kom, M.Cs