[python] HTTPie를 사용하여 SOAP API를 호출하는 방법은 어떻게 되나요?

먼저, HTTPie를 설치해야 합니다. 다음 명령을 사용하여 설치할 수 있습니다:

pip install httpie

설치가 완료되면, SOAP API의 엔드포인트 URL과 요청을 위한 SOAP XML 데이터를 준비해야 합니다. 예를 들어, 사용자 정보를 가져오는 SOAP API를 호출한다고 가정해봅시다.

다음은 HTTPie를 사용하여 SOAP API를 호출하는 명령의 예제입니다:

http POST https://api.example.com/soap \
    SOAPAction:"getUserInfo" \
    Content-Type:text/xml \
    --body '<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <getUserInfoRequest>
                <username>john@example.com</username>
                <password>strongpassword</password>
            </getUserInfoRequest>
        </soap:Body>
    </soap:Envelope>'

위의 예제에서는 http POST 명령을 사용하여 POST 요청을 보내고 있습니다. 엔드포인트 URL은 https://api.example.com/soap이며, SOAPAction 헤더를 통해 호출할 SOAP 액션을 지정합니다. Content-Type 헤더는 text/xml을 사용하고, 요청 본문 (SOAP XML 데이터)은 --body 플래그를 통해 전달됩니다.

실행한 결과로는 SOAP API의 응답이 출력됩니다.

더 자세한 HTTPie 사용법은 공식 문서를 참조하시면 됩니다.