한국어
Qt
 

SOAP(Simple Object Access Protocol)은 일반적으로 널리 알려진 HTTP, HTTPS, SMTP 등을 통해 XML 기반의 메시지를 네트워크상에서 교환하는 프로토콜이다.

KDSoap.png

 

원격 프로시져 호출(Remote Procedure Call:RPC) 패턴으로, 네트워크 노드(클라이언트)에서 다른 쪽 노드(서버)쪽으로 메시지를 요청 하고, 서버는 메시지를 즉시 응답하게 된다.

 

KDSoap은 Qt를 사용하는 C++응용 프로그램에서 SOAP 가능하도록 하는 3rd party 오픈소스 컴포넌트이다. 웹서비스 용 클라이언트 응용프로그램을 만드는데 사용될 수 있으며 전용 웹 서버와 같은 추가구성요소 없이 웹서비스를 생성할 수 있는 수단을 제공한다.

 

빌드환경:
Windows10
mingw73-32
Qt5.12.4

 

소스코드 체크아웃
git clone https://github.com/KDAB/KDSoap.git
$ git checkout remotes/origin/kdsoap-1.9.0-release
 
Qt용 명령 프롬프트
E:\project\opensource\KDSoap>c:\Python27\python.exe autogen.py -shared -release
 
-- Using source directory: E:\project\opensource\KDSoap
-- Using repository information: revision=kdsoap-1.9.0 isTagged=True
-- Auto-generation done.
-- License marked as accepted.
-- Wrote build files to: E:\project\opensource\KDSoap
-- Now running configure script.
 
 
E:\project\opensource\KDSoap>Qt found: C:/Qt/Qt/5.12.4/mingw73_32
KDSoap v1.9.0 configuration:
 
  Debug...................: no (default: no)
  Release.................: yes (default: yes)
  Shared build............: yes (default: yes)
  Compiled-In Unit Tests..: no (default: no)
 
Info: creating stash file E:\project\opensource\KDSoap\.qmake.stash
Project MESSAGE: No install prefix given, using default of C:\KDAB\KDSoap-1.9.0 (use configure -prefix DIR to specify)
Project MESSAGE: Install prefix is C:\KDAB\KDSoap-1.9.0
Project MESSAGE: This is KD Soap version 1.9.0
Reading E:/project/opensource/KDSoap/kdwsdl2cpp/kdwsdl2cpp.pro
Reading E:/project/opensource/KDSoap/kdwsdl2cpp/libkode/libkode.pro
Reading E:/project/opensource/KDSoap/kdwsdl2cpp/common/common.pro
Reading E:/project/opensource/KDSoap/kdwsdl2cpp/schema/schema.pro
Reading E:/project/opensource/KDSoap/kdwsdl2cpp/wsdl/wsdl.pro
Reading E:/project/opensource/KDSoap/kdwsdl2cpp/src/src.pro
  Reading E:/project/opensource/KDSoap/kdwsdl2cpp/src/kdwsdl2cpp_lib.pro
  Reading E:/project/opensource/KDSoap/kdwsdl2cpp/src/kdwsdl2cpp.pro
Reading E:/project/opensource/KDSoap/src/src.pro
Reading E:/project/opensource/KDSoap/src/KDSoapClient/KDSoapClient.pro
Reading E:/project/opensource/KDSoap/src/KDSoapServer/KDSoapServer.pro
Reading E:/project/opensource/KDSoap/features/features.pro
Reading E:/project/opensource/KDSoap/include/include.pro
Reading E:/project/opensource/KDSoap/include/KDSoapClient/KDSoapClient.pro
Reading E:/project/opensource/KDSoap/include/KDSoapServer/KDSoapServer.pro
Reading E:/project/opensource/KDSoap/examples/examples.pro
Reading E:/project/opensource/KDSoap/examples/helloworld_client/helloworld_client.pro
Reading E:/project/opensource/KDSoap/examples/helloworld_server/helloworld_server.pro
Reading E:/project/opensource/KDSoap/examples/bank_gui/bank_gui.pro
Reading E:/project/opensource/KDSoap/examples/bank_wsdl/bank_wsdl.pro
Ok, now run nmake (for Visual Studio) or mingw32-make (for mingw) to build the framework.
 
빌드 및 설치:
mingw32-make

 

mingw32-make install

 

예제:

KDSoap\examples\helloworld_client

KDSoap\examples\helloworld_server

 

예제 프로젝트 폴더에서 다음과 같이 프로토콜을 정의한 xml 형식 파일이 있다. 컴파일 시 kdwsdl2cpp 에 의해 필요한 소스코드를 생성한다.

helloworld.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="HelloService"
   targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   <message name="SayHelloRequest">
      <part name="msg" type="xsd:string"/>
   </message>
   <message name="SayHelloResponse">
      <part name="reply" type="xsd:string"/>
   </message>
 
   <portType name="Hello_PortType">
      <operation name="sayHello">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>
   
   <binding name="Hello_Binding" type="tns:Hello_PortType">
      <soap:binding style="document" 
         transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="sayHello" style="document">
         <soap:operation soapAction="sayHello"/>
         <input>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </input>
         <output>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </output>
      </operation>
</binding>
 
   <service name="Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding="tns:Hello_Binding" name="Hello_Port">
         <soap:address location="http://localhost:8081/hello" />
      </port>
   </service>
</definitions>
 

 

예제를 빌드해서 서버를 실행 하고

server.png

 

클라이언트를 실행하여 메세지를 보내본다.

client.png

 

로컬(localhost)에서 서버와 클라이언트 프로세스간 통신하는데도 사용할 수 있다.

번호 제목 글쓴이 날짜 조회 수
공지 Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서 운영자 2019.01.05 85831
138 Qt 6 에서 프로퍼티 바인딩 makersweb 2021.04.03 769
137 QML과 JavaScript 의 숫자 관련 내장된 함수 makersweb 2021.03.28 1392
136 Qt 5 코드를 Qt 6로 포팅하기 위해 도움이 되는 Clazy Framework file makersweb 2021.03.01 921
135 C++로 작성한 클래스를 QML에서 생성 file makersweb 2021.02.10 5272
134 Qt MQTT의 pus/sub 튜토리얼 file makersweb 2021.02.06 1638
133 Qt 를 사용하거나 기반으로 하는 응용프로그램 updatefile makersweb 2021.01.30 3787
132 Loader를 사용하여 동적으로 QML 로드 makersweb 2021.01.19 1806
131 QThread 및 QMutex 예제 makersweb 2021.01.12 1345
130 그래픽 소프트웨어에서 디자인 내보내기 (Exporting Designs from Graphics Software) j2doll 2020.12.25 413
129 Qt5Compat 라이브러리를 사용하여 Qt5에서 Qt6로 포팅 [2] makersweb 2020.12.05 672
128 Qt Quick Controls 2에 네이티브 데스크탑 스타일 추가 file makersweb 2020.11.23 486
127 QML 바인딩 끊김 진단 makersweb 2020.11.08 908
126 QML과 코루틴(Coroutines) makersweb 2020.11.03 577
125 Qt 6의 비동기 API makersweb 2020.10.19 1198
124 QRandomGenerator 클래스를 사용하여 난수(random values) 생성 makersweb 2020.10.17 1569
123 Qt 6에서 QList 변경사항 makersweb 2020.10.08 973
122 Qt 6.0의 개발 호스트 및 대상 플랫폼 makersweb 2020.09.16 976
121 main함수 명령줄 옵션 해석 makersweb 2020.09.01 2228
120 UI 폼(Form)작성 시 탭 순서(Tab Order) 설정 file makersweb 2020.08.24 2770
119 Qt로 데이터를 직렬화(serialization)하는 방법 makersweb 2020.08.04 2052