SOAP

32
SOAP Simple Object Access Protocol

description

SOAP. Simple Object Access Protocol. Apakah SOAP?. Saat ini web adalah komunikasi antara manusia dan aplikasi. SOAP adalah komunikasi aplikasi ke aplikasi SOAP adalah lightweight protocol untuk pertukaran informasi yg terstruktur dalam lingkungan desentralisasi dan terdistribusi. - PowerPoint PPT Presentation

Transcript of SOAP

Page 1: SOAP

SOAP

Simple Object Access Protocol

Page 2: SOAP

Apakah SOAP?

• Saat ini web adalah komunikasi antara manusia dan aplikasi.

• SOAP adalah komunikasi aplikasi ke aplikasi• SOAP adalah lightweight protocol untuk

pertukaran informasi yg terstruktur dalam lingkungan desentralisasi dan terdistribusi.

• SOAP menggunakan XML technologies dalam mendefinisikan framework messagingnya

• framework ini dirancang independen terhadap berbagai model programming

Page 3: SOAP

• SOAP adalah communication protocol• SOAP adalah a format untuk sending

messages• SOAP dirancang untuk komunikasi via Internet• SOAP adalah platform independent• SOAP adalah language independent• SOAP adalah simple and extensible• SOAP bisa melewati firewalls• SOAP adalah W3C standard

Page 4: SOAP

SOAP Architecture

• Spesifikasi SOAP terdiri dari 4 bagian:– SOAP envelope: menjelaskan format dari SOAP

message.– SOAP encoding: menggambarkan dari

representasi data yang dikirim dalam sebuah pesan.

– SOAP RPC: mendefinisikan bagaimana SOAP message dapat mengeksekusi remote procedure calls (RPCs).

– SOAP binding framework: mendefinisikan protocol yang digunakan SOAP messages yang dikirim oleh aplikasi.

Page 5: SOAP

One way message

Page 6: SOAP

Request response

Page 7: SOAP

SOAP format

• SOAP message terdiri dari tiga bagian:– SOAP Envelope– SOAP Header

(optional)– SOAP Body

Page 8: SOAP

Contoh apache

Apache SOAPservice:

HelloService.java

Apache SOAP rpcrouter servlet

Apache SOAP client: HelloClient.java

Jakarta Tomcat server

SOAP request:Service name: urn:HelloWorldMethod name: sayHelloParameter: firstName=“Yuhong”

lastName=“YanSOAP response:

Return value: “Yuhong Yan, welcome to SOAP”

“Yuhong Yan, Welcome to SOAP…”sayHello(“Yuhong”,”Yan)

12

3

4

5Http POST

Http GET

Page 9: SOAP

SOAP Envelope

• SOAP Envelope mendefinisikan keseluruhan framework untuk menjawab– apa yang didalam message dan – siapa yang terlibat

• Envelope adalah top element dari XML document yang perepresentasikan message. – Envelope element selalu menjadi root element dari

SOAP message. – Envelope element terdiri dari

• optional Header element • Dan mandatory Body element.

Page 10: SOAP

SOAP Envelope Code

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <!-- optional -->

<!-- header blocks go here... --> </soap:Header> <soap:Body>

<!-- payload or Fault element goes here... --> </soap:Body>

</soap:Envelope>

Page 11: SOAP

Envelope element

penggunaan xmlns:soap namespace selalu menggunakan http://www.w3.org/2001/12/soap-envelope

Page 12: SOAP

EncodingStyle• SOAP encodingStyle attribute digunakan untuk mendefinisikan

type data yang digunakan dalam dokumen.• attribute ini bisa muncul pada setiap SOAP element, dan

berpengaruh hanya pada elemen tersebut dan childnya • SOAP message tidak mempunyai default encoding.

Page 13: SOAP

SOAP Header

• Header element adalah generic container untuk informasi kontrol

• Bisa berupa beberapa elements dari beberapa namespace

• Header berisi informasi proses dari message

• Header adalah optional

Page 14: SOAP

SOAP Header

<soap:Header>

<!-- security credentials -->

<s:credentials xmlns:s="urn:examples-org:security"> <username>dave</username> <password>evad</password>

</s:credentials>

</soap:Header>

Page 15: SOAP

Body

• Elemen body menjelaskan messagenya<soap:Body>

<x:TransferFunds xmlns:x="urn:examples-org:banking">

<from>22-342439</from> <to>98-283843</to> <amount>100.00</amount>

</x:TransferFunds> </soap:Body>

Page 16: SOAP

Contoh requestSOAP Message Embedded in HTTP Request:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  SOAPENV:encodingStyle="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>

Page 17: SOAP

Contoh responseSOAP Message Embedded in HTTP Response:

<SOAP-ENV:Envelope  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>   <SOAP-ENV:Body>       <m:GetLastTradePriceResponse xmlns:m="Some-URI">           <Price>34.5</Price>       </m:GetLastTradePriceResponse>   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Page 18: SOAP

SOAP Security

• SOAP specification tidak mendefinisikan encryption untukk XML Web Services.

• Diserahkan kepada implementer dari SOAP protocol.

• Encryption tergantung dari transport protocol • apakah transport protocol tersebut support

secure communication? • cost dari enkripsi semua data dibandingan

dengan sebagian data?

Page 19: SOAP

Contoh

<%@ WebService Language="C#" Class="CreditCardService" %>

using System.Web.Services;

public class CreditCardService { [WebMethod]

[EncryptionExtension(Encrypt=EncryptMode.Response)] public string GetCreditCardNumber() {

return "MC: 4111-1111-1111-1111"; }

}

Page 20: SOAP

Request yg dienkripsi

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<GetCreditCardNumber xmlns="http://tempuri.org/" />

</soap:Body>

</soap:Envelope>

Page 21: SOAP

Response yg dienkripsi

<soap:Body>

<GetCreditCardNumber xmlns="http://tempuri.org/">

<GetCreditCardNumberResult>83 151 243 32 53 95 86 13 190 134 188 241 198 209 72 114 122 38 180 34 194 138 16 97 221 195 239 86 26 152 94 27

</GetCreditCardNumberResult>

</GetCreditCardNumber>

</soap:Body>

Page 22: SOAP

SOAP Fault Element

• Error mesage dari SOAP mesage dimasukkan kedalam Fault element.

• (optional) jika Fault element ada, maka harus muncul sebagai elemen child pada Body element.

• Fault element hanya muncul sekali dalam SOAP message.

Page 23: SOAP

SOAP Fault Element

SOAP Fault element mempunyai sub elements:• <faultcode >

A code for identifying the fault

• <faultstring > A human readable explanation of the fault

• <faultactor > information about who caused the fault to happen URI value identifying the source

• <detail> error information related only to the Body element. if not present then indicates that the fault is not related to the Bodyelement.

Page 24: SOAP

faultcode

Page 25: SOAP

Contoh

Page 26: SOAP

HTTP

• HTTP communicates over TCP/IP.• An HTTP client connects to an HTTP server

using TCP.• After establishing a connection, the client can

send an HTTP request message to the server:

POST /item HTTP/1.1Host: 189.123.345.239Content-Type: text/plainContent-Length: 200

Page 27: SOAP

HTTP

• The server then processes the request and sends an HTTP response back to the client.

• The response contains a status code that indicates the status of the request:

Page 28: SOAP

SOAP HTTP Binding

• A SOAP method is an HTTP request/response that complies with the SOAP encoding rules.

HTTP + XML = SOAP

• A SOAP request could be an HTTP POST or an HTTP GET request.

• POST -- Send• GET -- Retrieve

Page 29: SOAP

SOAP request and response

• The Content-Type header for a SOAP request and response defines– the MIME type for the message and– the character encoding (optional)

• used for the XML body of the request or response.

Page 30: SOAP

SOAP request and response

• The Content-Length header for a SOAP request and response specifies the number of bytes in the body of the request or response.

Page 31: SOAP

Contoh • GetStockPrice request is sent to a server. The request has a

StockName parameter, and a Price parameter will be returned in the response. The namespace for the function is defined in http://www.example.org/stock address.

• The SOAP request:

Page 32: SOAP