본문 바로가기
CS/기타 개념

[웹 개념] SOAP, WSDL 이란?

by 노잼인간이라불립니다 2022. 6. 29.

SOAP(Simple Object Access Protocol) 

  - HTTP, HTTPS, SMTP 등을 통해 XML 기반의 메시지를 컴퓨터 네트워크 상에서 교환하는 프로토콜이다.

  - SOAP은 웹 서비스에서 기본적인 메시지를 전달하는 기반이 된다.

  - SOAP에는 몇 가지 형태의 메시지 패턴이 있지만 보통 RPC(Remote Procedure Call)패턴을 사용한다.(함수를 불러서 데이터 가져온다. API를 불러오는 것 같은 느낌)

  - RPC란 네트워크 노드(클라이언트)에서 다른쪽 노드(서버)로 메시지를 요청하고, 서버는 메시지를 즉시 응답하게 된다.

  - SOAP은 XML-RPC와 WDDX에서 envelope/header/body로 이루어진 구조와 전송(transport)과 상호 중립성(interaction neutrality)의 개념을 가져왔다.

  - SOAP은 XML을 근간으로 헤더와 바디를 조합하는 디자인 패턴으로 설계되어 있다. 

  - 헤더는 선택사항으로 반복이나 보안 및 트랜잭션을 정보로 하는 메타 정보를 가지고 있다.

  - 바디 부분은 주요한 정보를 가지고 있다.

 

  * 원격 프로시저 호출(영어remote procedure call, 리모트 프로시저 콜, RPC)은 별도의 원격 제어를 위한 코딩 없이 다른 주소 공간에서 함수나 프로시저를 실행할 수 있게하는 프로세스 간 통신 기술이다.

 원격 프로시저 호출을 이용하면 프로그래머는 함수가 실행 프로그램에 로컬 위치에 있든 원격 위치에 있든 동일한 코드를 이용할 수 있다.

 

*WDDX (Web Distributed Data eXchange)는 다른 환경과 다른 컴퓨터 간에 데이터를 전달하도록 설계된 프로그래밍 언어 , 플랫폼 및 전송 중립적인 데이터 교환 메커니즘입니다.

 

전송방식

  - SOAP는 인터넷 애플리케이션 계층에 있는 프로토콜을 전송계층의 프로토콜로 사용할 수 있게 만든다. 혹자는 이러면 프로토콜의 의도된 목적과 역할이 맞지 않아 부정 이용이 된다고 비판하지만, SOAP의 지지자들은 터널링을 위한 다양한 계층(level)에 쓰이고 있는 다른 프로토콜들과 비슷하다고 말하고 있다.

 

  -  SMTP와 HTTP에서 애플리케이션 계층 프로토콜로 트랜스포트 계층의 역할을 대신하는 것이 SOAP의 올바른 이용이라 할 수 있으나, HTTP는 오늘날 인터넷 인프라와 매우 잘 동작하여 더욱 폭넓은 지원을 가능하게 한다. 

 

  - 특히나, HTTP는 방화벽이 작동하는 네트워크 안에서도 문제 없이 작동한다. SOAP는 HTTPS(애플리케이션 계층에서는 HTTP와 동일하나 트랜스포트 계층 아래에서는 암호화됨)에서도 간략하게 또는 상호적으로 사용된다.

 

장점

  • SOAP은 융통성있게도 각각 다른 트랜스포트 프로토콜들의 사용을 허용하고 있다. 표준 스택에서는 트랜스 포트 프로토콜로 HTTP를 사용하지만, 다른 프로토콜 역시 사용가능 하다.
  • SOAP은 플랫폼 독립적이다.
  • SOAP은 프로그래밍 언어에 독립적이다.
  • SOAP은 확장가능하다.

분산환경 하에서 정보교환을 하기 위한 하나의 프로토콜인 SOAP은 다음과 같은 장점을 가지고 있다(안현수, 2003).

  1. SOAP은 전송(Transport) 매체로서 HTTP를 사용하기 때문에 인터넷에서 널리 사용할 수 있다. 실제로 SOAP은 인터넷에서 원격 객체를 액세스하기 위해 고안된 프로토콜이다.
  2. SOAP은 HTTP와 XML을 사용하기 때문에 개발도구나 플랫폼에 구애받지 않고 SOAP 서버 혹은 클라이언트를 개발할 수 있다. 이처럼 SOAP 서버 혹은 클라이언트를 보다 쉽게 개발할 수 있도록 해주는 COM 컴포넌트, 유틸리티 등으로 구성된 SOAP 툴킷(toolkit)도 제공되고 있다. 또한 HTTP와 XML이 갖는 장점을 모두 포함하면서 컴포넌트의 상호운용성을 높일 수도 있다.
  3. SOAP은 컴포넌트를 활성화하는 방법이나 호출하는 방법에 대해 전혀 관여하지 않으며 이에 대한 상세한 사항은 HTTP Request를 수신하는 수신자에게 위임하고 있다. 따라서 객체지향기술이나 컴포넌트 기술을 사용하지 않는 애플리케이션일지라도 SOAP을 통해 객체서비스를 제공하거나 제공받을 수가 있다.(이수상, 디지털도서관 운영론. 서울: 한국도서관 협회. 2013. P.281)

단점

  • XML 포맷은 태그 형태로 보내기 때문에 CORBA같은 미들웨어 기술과 비교해서 상대적으로 느리다. 이것은 전송할 메시지가 적을때에는 문제 되지 않을 수 있다. 성능을 향상시키기 위해서 바이너리 객체를 포함시킨 특별한 경우의 XML(바이너리 XML을 말하는듯)로 메시지 전송 최적화 메커니즘(Message Transmission Optimization Mechanism; MTOM)이 나왔다. 게다가 일반적인 XML의 성능을 향상시키기 위해, VTD-XML과 같은 emerging non-extractiv XML 처리 모델이 있다.

SOAP 샘플

 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP-ENV:Body>
 <getProductDetails xmlns="http://warehouse.example.com/ws">
 <productId>827635</productId>
 </getProductDetails>
 </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>

 

 

 

출처 - 위키백과(https://ko.wikipedia.org/wiki/SOAP)

 

 

 

WSDL(Web Services Description Language)이란?

 

 WSDL(Web Services Description Language의 약자)은 웹 서비스 기술언어 또는 기술된 정의 파일의 총칭으로 XML로 기술된다. 웹 서비스의 구체적 내용이 기술되어 있어 서비스 제공 장소, 서비스 메시지 포맷, 프로토콜 등이 기술된다.

 

 WSDL은 네트워크의 엔드포인트나 포트의 총집합으로서의 서비스를 기술한다. WSDL의 사양은 XML 형식을 제공한다. WSDL은 자주 SOAP와 XML 스키마와 결합하여 인터넷 상에 웹 서비스를 제공하기 위해 사용되기도 한다. 웹 서비스에 연결되는 클라이언트 프로그램은 WSDL 파일을 읽어들여 서버에 어떠한 조작이 가능한지를 결정할 수 있다.

 

 현재의 WSDL 버전은 2.0이다. 버전 1.1은 W3C에 의해 서명되지 않았으나 버전 2.0은 W3C 권고안이다.

(“Web Services Definition Language (WSDL) Version 2.0 Part 1: Core Language”. 2007년 6월 27일에 확인함.)

 1.1버전까지는 WSDL의 D는 Definition을 뜻하였다. WSDL 1.2가 WSDL 2.0으로 바뀐 이유는 WSDL 1.1과의 근본적인 차이 때문이다. 모든 HTTP 요청 메소드에 바인드하는 것을 허용함으로써(버전 1.1에서처럼 GET, POST뿐 아니라) WSDL 2.0 사양은 RESTful 웹 서비스에 대한 더 나은 지원을 제공하며 구현하기가 훨씬 더 쉬워졌다.

(“Web Services Definition Language (WSDL) Version 2.0 Part 2: Adjuncts”.)(“WITW WSDL 2.0 HTTP Binding”. 2012년 6월 20일에 원본 문서에서 보존된 문서. 2016년 3월 29일에 확인함.)

 

예제

WSDL 2.0 문서의 구조:

<?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 -->
   <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>



<!-- 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>

출처 - 위키백과 (https://ko.wikipedia.org/wiki/WSDL)