[CS/네트워크] WSDL

황제연·2025년 6월 17일

CS학습

목록 보기
108/194
post-thumbnail

WSDL란?

WSDL(Web Service Description Language)는 XML 기반의 언어로
웹 서비스가 제공하는 기능과 이를 호출하는 방법을 기술하는 표준 문서입니다

웹 서비스를 정의하고 상호작용 방식을 표준화하기 위해 만들어졌으며,
주로 SOAP기반의 웹 서비스에서 사용됩니다

WSDL의 구조와 구성요소

WSDL은 주로 다음과 같은 요소들로 구성됩니다.

definitions

WSDL 문서의 루트 요소로, 웹 서비스의 이름, 네임스페이스,
사용될 타입 정의 및 다른 모든 요소들을 감싸는 컨테이너 역할을 합니다

types

XML Schema Definition(XSD)를 사용하여 데이터 타입을 정의하는 요소입니다
복잡한 자료구조나 사용자 정의 데이터를 기술할 때 사용됩니다

message

서비스에서 주고받는 메시지 구조를 정의합니다
각 메시지는 하나 이상의 파트(part)로 나뉘며, 각 파트는 데이터 타입을 명시합니다

portType

추상적으로 제공되는 웹 서비스의 인터페이스를 정의합니다
메시지 교환 패턴(입력, 출력, 오류 등)을 묶어서 하나의 인터페이스로 나타냅니다

binding

portType에서 정의한 추상적 인터페이스를 구체적인 프로토콜과
데이터 형식으로 구현하는 방법을 정의합니다

service

하나 이상의 포트를 묶어서 실제 웹 서비스가 제공되는 위치를 나타냅니다
port는 특정 binding과 실제 주소를 연결하여 최종적으로 서비스 접근 방법을 명시합니다

WSDL 문서의 예시

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             targetNamespace="http://example.com/wsdl">

  <types>
    <xs:schema targetNamespace="http://example.com/schema">
      <xs:element name="getOrder" type="xs:int" />
      <xs:element name="getOrderResponse" type="xs:string" />
    </xs:schema>
  </types>

  <message name="getOrderRequest">
    <part name="orderId" element="xs:getOrder"/>
  </message>
  
  <message name="getOrderResponse">
    <part name="orderInfo" element="xs:getOrderResponse"/>
  </message>

  <portType name="OrderServicePortType">
    <operation name="GetOrder">
      <input message="tns:getOrderRequest"/>
      <output message="tns:getOrderResponse"/>
    </operation>
  </portType>

  <binding name="OrderServiceBinding" type="tns:OrderServicePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="GetOrder">
      <soap:operation soapAction="http://example.com/GetOrder"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>

  <service name="OrderService">
    <port name="OrderServicePort" binding="tns:OrderServiceBinding">
      <soap:address location="http://example.com/orders"/>
    </port>
  </service>

</definitions>

SOAP Action이란?

SOAP 요청 시 클라이언트는 HTTP 헤더 중 SOAPAction 필드를 통해
호출하려는 작업의 URI 또는 액션 이름을 지정합니다

이는 서버가 수신한 SOAP 메시지를 어떤 서비스 연산(Operations)에 매핑할지
결정하는 단서를 제공합니다

  • 역할: HTTP 요청을 처리하는 서버가 WSDL의 binding 요소에 정의된 특정 operation을 식별하도록 돕습니다
  • 형식: SOAPAction: "http://example.com/GetOrder"
  • 매핑: WSDL <binding> 아래 <soap:operation soapAction="..."/> 속성과 일치시켜 해당 SOAP 바디를 올바른 portTypeoperation으로 연결합니다.

서버는 HTTP 헤더 SOAPAction 값과 WSDL에 정의된 soapAction을 비교하여
들어온 메시지를 올바른 operation으로 처리합니다

WSDL과 SOAP의 연관성

WSDL은 특히 SOAP와 연관성을 가집니다
SOAP는 웹 서비스 간의 메시지 교환 프로토콜로 사용되며,
WSDL은 이 메시지 교환이 어떻게 이루어질지에 대한 정의를 제공합니다

마치 REST API에 대한 Swagger문서와 같다고 생각하면 됩니다

WSDL의 장점

서비스의 구조를 명확히 하여 개발과 유지보수성을 보장합니다

WSDL의 단점

WSDL은 XML 기반이기 때문에 복잡성이라는 태생적인 단점이 존재합니다

profile
Software Developer

0개의 댓글