SOAP 另一種跟伺服器溝通的協議

了解一下。

概論

SOAP(Simple Object Access Protocol)

首先,SOAP 都是基於「XML」來做資料交換(溝通),所以如果你要跟一個提供 SOAP 服務的伺服器溝通,大概會是這樣子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- 用戶端發的 request -->
<?xml version="1.0"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cal="http://www.stgregorioschurchdc.org/Calendar">
<!-- header -->
<soapenv:Header/>
<!-- body -->
<soapenv:Body>
<cal:easter_date soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<year xsi:type="xsd:short">2014</year>
</cal:easter_date>
</soapenv:Body>
</soapenv:Envelope>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- 伺服端回傳的 response -->
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<!-- body -->
<SOAP-ENV:Body>
<namesp1:easter_dateResponse
xmlns:namesp1="http://www.stgregorioschurchdc.org/Calendar">
<s-gensym3 xsi:type="xsd:string">2014/04/20</s-gensym3>
</namesp1:easter_dateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

其實就跟 HTTP 的概念很類似,只是都改成用 XML 的資料格式來做溝通。

關於 IP 地址 HTTP 懶人包
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×