SOAP/WSDL vs REST
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
API์ ๊ตฌ์กฐ๋ฅผ ์ด์ผ๊ธฐํ ๋, ๋ํ์ ์ผ๋ก SOAP๊ณผ REST๊ฐ ํํ ๋น๊ต๋๋ค. SOAP์ ํ๋กํ ์ฝ์ด๋ฉฐ, REST๋ ์ํคํ ์ณ ์คํ์ผ์ด๊ธฐ ๋๋ฌธ์ด๋ค.
SOAP๋ ๋ถ์ฐ ์ปดํจํ ํ๊ฒฝ์ ์ํด ์ค๊ณ๋์์ผ๋ฉฐ REST๋ ์ง์ ๊ฐ ํ๊ฒฝ์ ์ํด ์ค๊ณ๋์๋ค.
WADL์ ์ฌ์ฉํ์ฌ REST ์๋น์ค์ ๋ํ ์ธํฐํ์ด์ค๋ฅผ ์ ์ ํ ์ ์๋ค.
SOAP(Simple Object Access Protocol)์ ์ผ๋ฐ์ ์ผ๋ก ๋๋ฆฌ ์๋ ค์ง HTTP, HTTPS, SMTP ๋ฑ์ ํตํด XML ๊ธฐ๋ฐ์ ๋ฉ์์ง๋ฅผ ์ปดํจํฐ ๋คํธ์ํฌ ์์์ ๊ตํํ๋ ํ๋กํ ์ฝ์ด๋ค. -์ํคํผ๋์-
SOAP๋ SOA๋ฅผ ๋ฐ๋ฅด๋ ์น์๋น์ค ๋์์ธ ํ์ค์ด๋ฉฐ, WSDL(Web Services Description Language)์ ์ด์ฉํด ์ ์ํ๋ค. XML์ ๊ธฐ๋ฐ์ผ๋ก ํค๋์ ๋ฐ๋๋ฅผ ์กฐํฉํ๋ ๋์์ธํจํด์ผ๋ก ์ค๊ณ๋๋ค.
ํ๋ซํผ๊ณผ ํ๋ก๊ทธ๋๋ฐ์ ๋ ๋ฆฝ์ ์ด๋ค.
๋ถ์ฐ์ปดํจํ ํ๊ฒฝ์์ ์ฌ์ฉํ๊ธฐ ์ํ ๋์์ธ์ด๋ค.(์์ฒญ๊ณผ ์๋ต์ด ๋งค์ฐ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌ์ฑ๋๊ณ DTD๋ฅผ ์ฌ์ฉํ ์ ์๋ค)
์น์๋น์ค๋ฅผ ์ํด ๋๋ฆฌ ์ฌ์ฉํ๋ ํ์ค์ด๋ฉฐ, ํ์ฅ์ฑ์ด ๋ฐ์ด๋๋ค.
์ด๋ ต๊ณ , ๋ฌด๊ฒ๊ณ , ๋๋ฆฌ๋ค.
์ฆ, ์์ฌ ์ํต๊ณผ ๊ฐ์ ์๊ฒฉํ ๊ณ์ฝ์ ์ฒด๊ฒฐํด์ผํ๋ ๊ฒฝ์ฐ์ ์ ์ฉ ํ๋ค.
SOA๋ ๋๊ท๋ชจ ์ปดํจํฐ ์์คํ ์ ๊ตฌ์ถํ ๋์ ๊ฐ๋ ์ผ๋ก ์ ๋ฌด์์ ์ผ ์ฒ๋ฆฌ์ ํด๋นํ๋ ์ํํธ์จ์ด ๊ธฐ๋ฅ์ ์๋น์ค๋ก ํ๋จํ์ฌ ๊ทธ ์๋น์ค๋ฅผ ๋คํธ์ํฌ์์ ์ฐ๋ํ์ฌ ์์คํ ์ ์ฒด๋ฅผ ๊ตฌ์ถํด ๋๊ฐ๋ ๋ฐฉ๋ฒ๋ก ์ด๋ค. ์ํคํผ๋์
์ฆ, ๋น์ฆ๋์ค ์ํํธ์จ์ด๋ฅผ ๋ ๋ฆฝ์ ์ธ ์๋น์ค๋ก ๋ถ๋ฆฌํ์ฌ ์์คํ ์ ๊ตฌ์ถํ๋ฉฐ, ์ด๋ก ์ธํด ๊ฐ ์๋น์ค๋ค์ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ๋ฌถ์ด ์๋ก์ด ์๋น์ค๋ฅผ ๋ง๋ค์ด ๋ผ ์ ์๋ค. ๊ณต๊ธ์ ์ฒด์ ํ๋ ฅ์ ์ฒด ๋ฐ ๊ณ ๊ฐ๋ค๊ณผ ์ฐ๊ฒฐํ๋ ์๋ก์ด ๋ฐฉ๋ฒ์ ํ๋ณดํ ์ ์๊ณ ๋ณํ ์๊ตฌ์์ ์ ์ํ ๋ฐ์ํ ์ ์๋ค๋ ๊ฒ์ด๋ค.
WSDL์ ์น ์๋น์ค ๊ธฐ์ ์ธ์ด ๋๋ ๊ธฐ์ ๋ ์ ์ ํ์ผ์ ์ด์นญ์ผ๋ก XML๋ก ๊ธฐ์ ๋๋ค. ์น ์๋น์ค์ ๊ตฌ์ฒด์ ๋ด์ฉ์ด ๊ธฐ์ ๋์ด ์์ด ์๋น์ค ์ ๊ณต ์ฅ์, ์๋น์ค ๋ฉ์์ง ํฌ๋งท, ํ๋กํ ์ฝ ๋ฑ์ด ๊ธฐ์ ๋๋ค. - ์ํคํผ๋์ -
WSDL์ SOAP๊ณผ XML ์คํค๋ง๋ฅผ ๊ฒฐํฉํด ์ธํฐ๋ท ์์ ์น ์๋น์ค๋ฅผ ์ ๊ณตํ๊ธฐ ์ํด ์ฌ์ฉํ๋ฉฐ, ์๋์ ๊ฐ์ ์ ๋ณด๋ฅผ ๋ด๊ณ ์๋ค.
์น ์๋น์ค์ name, URL ์ ๋ณด
SOAP ๋ฉ์ธ์ง์ ์ธ์ฝ๋ฉ ๊ท์น
SOAP ๋ฉ์ธ์ง ์ ์ก์ ์ํ ํ๋กํ ์ฝ ์ ๋ณด
์น์๋น์ค๋ฅผ ์ด์ฉํ๋๋ฐ ํ์ํ ์ธํฐํ์ด์ค ์ ๋ณด(type, including name, operations, parameter, data)
<description>
<types></types>
<interface></interface>
<binding></binding>
<service></service>
</description>
2.0๋ฒ์ ์ ์์ ํํ๋ก ๊ตฌํ๋์ด ์์ผ๋ฉฐ, ์๋๋ ์์์ด๋ค.
types(types,message)
๋ฉ์ธ์ง๋ ํ๋ก์์ ์ ๋ํ ๋ฐ์ดํฐ ํ์ ์ค์
๋ฉ์ธ์ง ์ ์ก๊ณผ ๊ด๋ จ๋ ๋ฐ์ดํฐ ํฌ๋งท ์ ์
interface(portType)
WSDL๋ฌธ์๋ ์ด์ ๊ฐ์ด ๊ตฌ์ฒด์ ์ผ๋ก ๋ฌผ๋ฆฌ์ ์ธ ๋ถ๋ถ(๋ฐ์ดํฐ ํ์ )์์ ์ถ์์ ์ด๊ณ ๋ ผ๋ฆฌ์ ์ธ ๋ถ๋ถ(์ธํฐํ์ด์ค)๊น์ง ๋ชจ๋ ํฌ๊ดํด ์ฐธ์กฐ ๊ฐ๋ฅ
binding
๋ ผ๋ฆฌ์ ๋ชจ๋ธ๊ณผ ๋ฌผ๋ฆฌ์ ๋ชจ๋ธ ์ฌ์ด์ ์ฐ๊ฒฐ์ ์ ๊ณต
์ด๋ฏธ ์ ์ํ ์ถ์์ ์ธ ํฌํธํ์ ์ ์๋ SOAP๋ฅผ ์ด๋ป๊ฒ ์ ์กํ ๊ฒ์ธ์ง ๊ตฌ์ฒด์ ์ผ๋ก ๊ธฐ์ ํ ์ค์ ํฌํธ์ ์ฐ๊ฒฐ
SOAP์ HTTP์ SMTP๊ฐ์ ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ฉด ํ๋ก์๋ ๋ฐฉํ๋ฒฝ์ ํต๊ณผํ ์ ์์ง๋ง, ๋ณด์์ฑ์ ์์ด์๋ ์ทจ์ฝ
service
ํฌํธ ํ์ ๊ณผ ๋ฐ์ธ๋ฉ์ ์ด์ฉํด์ ์๋น์ค์ ๋ํ ์น ์ฃผ์ ๋๋ URL ์ง์
SOAP ์๋ฒ๋ฅผ ์ค์ ํ ์์น๋ฅผ ์ง์ ํ๋ ๊ฒ์ด ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://www.w3.org/ns/wsdl"
xmlns:tns="http://www.example.com/wsdl20sample"
xmlns:whttp="http://www.w3.org/ns/wsdl/http"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
targetNamespace="http://www.example.com/wsdl20sample">
<!-- Abstract types(๋ฐ์ดํฐ ํ์
/method์ ์ธ์์ ๋ฆฌํด ๊ฐ ์ ์ธ) -->
<types>
<xs:schema xmlns="http://www.example.com/wsdl20sample"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/wsdl20sample">
<xs:element name="request">
<xs:complexType>
<xs:sequence>
<xs:element name="header" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="body" type="xs:anyType" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="method" type="xs:string" use="required"/>
<xs:attribute name="uri" type="xs:anyURI" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="response">
<xs:complexType>
<xs:sequence>
<xs:element name="header" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="body" type="xs:anyType" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="status-code" type="xs:anySimpleType" use="required"/>
<xs:attribute name="response-phrase" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<!-- Abstract interfaces : ์ธํฐํ์ด์ค ์ ์ -->
<interface name="RESTfulInterface">
<fault name="ClientError" element="tns:response"/>
<fault name="ServerError" element="tns:response"/>
<fault name="Redirection" element="tns:response"/>
<operation name="Get" pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="GetMsg" element="tns:request"/>
<output messageLabel="SuccessfulMsg" element="tns:response"/>
</operation>
<operation name="Post" pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="PostMsg" element="tns:request"/>
<output messageLabel="SuccessfulMsg" element="tns:response"/>
</operation>
<operation name="Put" pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="PutMsg" element="tns:request"/>
<output messageLabel="SuccessfulMsg" element="tns:response"/>
</operation>
<operation name="Delete" pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="DeleteMsg" element="tns:request"/>
<output messageLabel="SuccessfulMsg" element="tns:response"/>
</operation>
</interface>
<!--binding : ์ค์ ๋คํธ์ํฌ protocol๊ณผ protType ๋งคํ ์ฆ, ์ด๋ป๊ฒ ์ฃผ๊ณ ๋ฐ์์ง-->
<!-- Concrete Binding Over HTTP -->
<binding name="RESTfulInterfaceHttpBinding" interface="tns:RESTfulInterface"
type="http://www.w3.org/ns/wsdl/http">
<operation ref="tns:Get" whttp:method="GET"/>
<operation ref="tns:Post" whttp:method="POST"
whttp:inputSerialization="application/x-www-form-urlencoded"/>
<operation ref="tns:Put" whttp:method="PUT"
whttp:inputSerialization="application/x-www-form-urlencoded"/>
<operation ref="tns:Delete" whttp:method="DELETE"/>
</binding>
<!-- Concrete Binding with SOAP-->
<binding name="RESTfulInterfaceSoapBinding" interface="tns:RESTfulInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/"
wsoap:mepDefault="http://www.w3.org/2003/05/soap/mep/request-response">
<operation ref="tns:Get" />
<operation ref="tns:Post" />
<operation ref="tns:Put" />
<operation ref="tns:Delete" />
</binding>
<!-- Web Service offering endpoints for both the bindings-->
<service name="RESTfulService" interface="tns:RESTfulInterface">
<endpoint name="RESTfulServiceRestEndpoint"
binding="tns:RESTfulInterfaceHttpBinding"
address="http://www.example.com/rest/"/>
<endpoint name="RESTfulServiceSoapEndpoint"
binding="tns:RESTfulInterfaceSoapBinding"
address="http://www.example.com/soap/"/>
</service>
</description>
REST(Representational State Transfer)๋ ํ์ค์ ์ ์ํ์ง ์๋ ์ํคํ ์ฒ ์คํ์ผ์ด๋ค. ์ผ๋ฐ์ ์ผ๋ก JSON์ด ๋ง์ด ์ฌ์ฉ๋์ง๋ง, XML, YAML๋ฑ protocol์ ๊ฐ์ ํ์ง ์๋๋ค.
ํ๋ซํผ, ํ๋ก๊ทธ๋๋ฐ์ ๋ ๋ฆฝ์ ์ด๋ค.
๊ฐ๋ณ๊ณ ๋น ๋ฅด๊ณ ์ฝ๋ค.
ํ์์ ๊ตฌ์ ๋ฐ์ง ์๋๋ค.(XML, JSON, HTML ๋ฑ ๋ฌด์์ด๋ ์ฌ์ฉ ๊ฐ๋ฅ)
HTTP ํ๋กํ ์ฝ์์๋ง ์ฌ์ฉ๊ฐ๋ฅํ๋ค.
๋ถ์ฐํ๊ฒฝ์ ๋น์ ํฉํ๋ค.(point to point ํต์ ๋ชจ๋ธ ๊ฐ์ )
๋ณด์, ์ ์ฑ ๋ฑ์ ํ์ค์ด ์๋ค.
RESTful์ ๋ํด์ ๋ ์์๋ณด๊ธฐ