how do you send a SOAP request?

On linux you can use curl to send the soap xml. Here's how to do it:

curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction: ACTION_YOU_WANT_TO_CALL" --data @FILE_NAME URL_OF_THE_SOAP_WEB_SERVICE_ENDPOINT

Using the testRequest.xml file created you can

curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction: ACTION_YOU_WANT_TO_CALL" --data @testRequest.xml URL_OF_THE_SOAP_WEB_SERVICE_ENDPOINT

Here is a link that describes the full process.


Opening this document in browser wouldn't send a request. You have several options:

  • write a little script in any familiar language, script should connect to specified server and send a POST request with a body as mentioned in your message
  • use some of existing programs to do that for you

If you're inexperienced I would definitely recommend second option. My personal favourite is SoapUI, see here.


You cannot send a soap request when a browser as far as I know. I propose you use a tool like Soap UI

to send a request.


This blog post helped me. Python SOAP Request using Requests

#!/usr/bin/env python
# encoding: utf-8

import requests
from XML import XML

request = u"""<?xml version="1.0" encoding="utf-8"?>
              <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
                  <soapenv:header>
                  <soapenv:body>
                      <web:conversionrate>
                          <web:fromcurrency>GBP</web:fromcurrency>
                          <web:tocurrency>CHF</web:tocurrency>
                      </web:conversionrate>
                  </soapenv:body>
              </soapenv:header></soapenv:envelope>"""

encoded_request = request.encode('utf-8')

headers = {"Host": "www.webservicex.net",
           "Content-Type": "text/xml; charset=UTF-8",
           "Content-Length": len(encoded_request)}

response = requests.post(url="http://www.webservicex.net/CurrencyConvertor.asmx",
                         headers = headers,
                         data = encoded_request,
                         verify=False)

print unicode(XML(response.text))

Tags:

Xml

Http

Soap