요즘 소프트웨어는 그 어느 때보다 강력합니다. 사용자를 위한 많은 정보와 기능을 제공할 수 있습니다. 애플리케이션의 점점 더 강력해지는 기능들 덕분에, 어떻게 모든 것이 가능한지 궁금해한 적이 있나요?
애플리케이션 개발의 과정에서 자주 등장하는 파일 유형 중 하나는 WSDL 파일입니다. 그런데 WSDL 파일이란 무엇인가요?
WSDL 파일이란 무엇인가요?
WSDL (웹 서비스 설명 언어) 파일은 서로 다른 애플리케이션이 네트워크를 통해 표준화된 방식으로 서로 통신할 수 있도록 허용합니다. 이는 웹 서비스 제공자와 소비자를 연결하여 두 당사자 간 데이터 교환을 가능하게 합니다.
WSDL 파일은 SOAP 기반 웹 서비스에 대한 많은 설명을 제공하는 것으로도 유명합니다. WSDL 파일은 XML (확장 가능 마크업 언어) 언어로 작성되며 SOAP API 테스트에 필수적입니다.
더욱 중요한 것은, WSDL 파일이 웹 서비스 제공자와 서비스 소비자 간의 공식적인 계약 정의로 인해 중요하다는 점입니다. WSDL 파일은 사용할 수 있는 작업, 메시지의 형식과 구조 및 웹 서비스를 사용할 때 필요한 기타 중요한 세부 사항을 보여줍니다.
WSDL 파일의 구조와 예시
WSDL 파일에는 이를 사용하는 데 필요한 정보를 제공하는 주요 구성 요소가 있습니다. 이 문서에서는 날씨 웹 서비스를 예로 들어 XML 언어로 WSDL 파일의 일부를 시연합니다.
유형 type
WSDL 파일의 type
섹션은 웹 서비스 작업에 사용될 데이터 유형을 정의하는 데 사용됩니다.
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/weather">
<element name="City" type="string"/>
<element name="Weather" type="string"/>
</schema>
</types>
이 예시는 City
와 Weather
라는 이름의 요소 구조를 정의하고 있으며 이들의 유형은 string
입니다.
메시지 message
message
섹션은 웹 서비스 제공자와 서비스 사용자 간에 교환되는 데이터 요소를 정의합니다. 위의 예에서 GetWeatherRequest
와 GetWeatherResponse
메시지의 이름을 확인할 수 있습니다.
<message name="GetWeatherRequest">
<part name="City" element="tns:City"/>
</message>
<message name="GetWeatherResponse">
<part name="Weather" element="tns:Weather"/>
</message>
여기서 GetWeatherRequest
와 GetWeatherResponse
메시지는 전송되거나 수신되는 데이터 요소를 지정하는 부분으로 정의됩니다.
포트 유형 portType
portType
섹션은 웹 서비스가 수행할 수 있는 작업 집합을 설명하며, GetWeather
라는 작업 이름을 포함합니다. 이는 서비스에 대한 추상 인터페이스를 정의하며, 입력 tns:GetWeatherRequest
와 출력 tns:GetWeatherResponse
메시지를 나열합니다.
<portType name="WeatherServicePortType">
<operation name="GetWeather">
<input message="tns:GetWeatherRequest"/>
<output message="tns:GetWeatherResponse"/>
</operation>
</portType>
위 예시는 WeatherServicePortType
에서 정의된 GetWeather
작업과 지정된 입력 및 출력 메시지를 보여줍니다.
바인딩 binding
binding
섹션은 portType
에서 정의된 추상 작업이 통신을 위해 구체적인 프로토콜에 어떻게 매핑되는지를 지정합니다. 메시지 형식 및 프로토콜(예: SOAP)과 같은 세부 사항을 정의합니다.
<binding name="WeatherServiceSoapBinding" type="tns:WeatherServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetWeather">
<soap:operation soapAction="http://example.com/weather/GetWeather"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
이 예시에서 WeatherServiceSoapBinding
는 바인딩 프로토콜로 SOAP를 정의하며, 메시지 형식 및 전송에 대한 세부 사항을 지정합니다.
포트 port
port
섹션은 웹 서비스에 접근할 수 있는 네트워크 주소를 지정합니다.
<service name="WeatherService">
<port name="WeatherServicePort" binding="tns:WeatherServiceSoapBinding">
<soap:address location="http://example.com/weather/service"/>
</port>
</service>
여기서 WeatherService
는 SOAP 바인딩을 사용하는 WeatherServicePort
로 정의되어 있으며, 그 주소는 http://example.com/weather/service
으로 지정되어 있습니다.
WSDL 파일의 예
간단한 날씨 웹 서비스 WSDL 파일 예시
앞서 제시된 다양한 주요 구성 요소 코드 조각을 컴파일하여, 간단한 날씨 웹 서비스 WSDL 파일을 생성할 수 있습니다.
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://example.com/weather"
targetNamespace="http://example.com/weather">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/weather">
<element name="City" type="string"/>
<element name="Weather" type="string"/>
</schema>
</types>
<message name="GetWeatherRequest">
<part name="City" element="tns:City"/>
</message>
<message name="GetWeatherResponse">
<part name="Weather" element="tns:Weather"/>
</message>
<portType name="WeatherServicePortType">
<operation name="GetWeather">
<input message="tns:GetWeatherRequest"/>
<output message="tns:GetWeatherResponse"/>
</operation>
</portType>
<binding name="WeatherServiceSoapBinding" type="tns:WeatherServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetWeather">
<soap:operation soapAction="http://example.com/weather/GetWeather"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="WeatherService">
<port name="WeatherServicePort" binding="tns:WeatherServiceSoapBinding">
<soap:address location="http://example.com/weather/service"/>
</port>
</service>
</definitions>
이 간단한 날씨 웹 서비스 예시에서 다음을 확인할 수 있습니다:
- 웹 서비스는
http://example.com/weather
네임스페이스 하에 운영됩니다. - 두 가지 단순 데이터 유형인
City
와Weather
가 정의됩니다. - 두 개의 메시지
GetWeatherRequest
와GetWeatherResponse
가 있으며, 이는GetWeather
작업의 입력 및 출력을 지정합니다. WeatherServicePortType
포트 유형은GetWeather
작업을 정의합니다.WeatherServiceSoapBinding
는 통신이 특정 스타일과 전송으로 SOAP를 사용할 것임을 지정합니다.WeatherService
서비스는 SOAP 바인딩을 사용하는WeatherServicePort
포트를 가지고 있으며, 그 주소는http://example.com/weather/service
입니다.
복잡한 전자 상거래 웹 서비스 WSDL 파일 예시
여기 여러 작업, 데이터 유형 및 기능을 포함한 더 복잡한 전자 상거래 웹 서비스 WSDL 파일 예시가 있습니다.
?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://example.com/ecommerce"
targetNamespace="http://example.com/ecommerce">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/ecommerce">
<element name="Product">
<complexType>
<sequence>
<element name="ProductId" type="string"/>
<element name="ProductName" type="string"/>
<element name="Price" type="decimal"/>
</sequence>
</complexType>
</element>
<element name="Order">
<complexType>
<sequence>
<element name="OrderId" type="string"/>
<element name="CustomerName" type="string"/>
<element name="Products" type="tns:Product" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="GetProductRequest">
<part name="ProductId" element="tns:ProductId"/>
</message>
<message name="GetProductResponse">
<part name="Product" element="tns:Product"/>
</message>
<message name="PlaceOrderRequest">
<part name="Order" element="tns:Order"/>
</message>
<message name="PlaceOrderResponse">
<part name="Confirmation" type="string"/>
</message>
<portType name="ECommerceServicePortType">
<operation name="GetProduct">
<input message="tns:GetProductRequest"/>
<output message="tns:GetProductResponse"/>
</operation>
<operation name="PlaceOrder">
<input message="tns:PlaceOrderRequest"/>
<output message="tns:PlaceOrderResponse"/>
</operation>
</portType>
<binding name="ECommerceServiceSoapBinding" type="tns:ECommerceServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetProduct">
<soap:operation soapAction="http://example.com/ecommerce/GetProduct"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="PlaceOrder">
<soap:operation soapAction="http://example.com/ecommerce/PlaceOrder"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ECommerceService">
<port name="ECommerceServicePort" binding="tns:ECommerceServiceSoapBinding">
<soap:address location="http://example.com/ecommerce/service"/>
</port>
</service>
</definitions>
이 복잡한 전자 상거래 웹 서비스 예제에서는 다음을 확인할 수 있습니다:
- 복잡한 데이터 유형
Product
와Order
가 중첩된 요소(ProductId
,ProductName
,Price
)와 시퀀스로 정의됩니다. ECommerceServicePortType
내에 여러 작업GetProduct
와PlaceOrder
가 정의됩니다.- 각 작업에 대해
GetProductRequest
,GetProductResponse
,PlaceOrderRequest
,PlaceOrderResponse
메시지가 정의되어 입력 및 출력 데이터를 지정합니다. - SOAP 바인딩
ECommerceServiceSoapBinding
는 SOAP를 사용하여 통신하기 위한 형식 세부 사항을 지정합니다. - 서비스
ECommerceService
는 SOAP 바인딩을 사용하는ECommerceServicePort
포트를 가지고 있으며, 그 주소는http://example.com/ecommerce/service
으로 지정됩니다.
Apidog를 사용한 WSDL 파일 편집
WSDL 파일은 소프트웨어 개발 환경에서 상대적으로 흔하므로, 직접 수정하거나 생성해야 할 수도 있습니다. 다양한 API 플랫폼 가운데, Apidog는 훌륭한 선택입니다.
Apidog는 개발자, 웹 서비스 제공자 및 다양한 배경의 웹 서비스 사용자들이 다른 API 플랫폼에서 Apidog로 원활하게 전환할 수 있도록 도와줍니다.
다행히도 Apidog는 WSDL 파일 가져오기 또한 지원합니다! 사용해 보고 싶다면 아래 버튼을 사용하여 Apidog를 다운로드하세요.
들어가면 로그인 하고 새로운 프로젝트를 시작하는 걸 잊지 마세요. 도움이 필요하시면 Apidog 도움말 문서를 참고하세요.
WSDL 파일에서 Apidog로 SOAP API 가져오기

새 프로젝트를 열면, Apidog 창의 왼쪽에 있는 수직 툴바에서 "설정" 버튼을 클릭합니다. 그런 다음 순서대로 화살표 2와 화살표 3을 클릭합니다.
Apidog에서 SOAP API 쉽게 테스트하기

WSDL 파일을 성공적으로 가져왔다면 화면 왼쪽에 그 이름이 표시됩니다(화살표 1 주위에 표시됨).
WSDL 파일 편집을 시작하려면 순차적으로 화살표 2에서 4를 클릭하면 됩니다!
결론
XML (확장 가능 마크업 언어)를 기반으로 한 WSDL 파일은 이해하기가 조금 더 쉽습니다. WSDL 파일은 웹 서비스의 설명과 기능이 얼마나 구체적인지에 따라 복잡성이 달라질 수 있습니다.