I am new to SOAP and xml. I read a number of tutorials but nothing seems to be clear enough.
I am abit confused, Just how does one send an SOAP request? The way I have t
Opening this document in browser wouldn't send a request. You have several options:
If you're inexperienced I would definitely recommend second option. My personal favourite is SoapUI, see here.
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))
You can use postman. It is good for REST and Soap https://learning.postman.com/docs/sending-requests/supported-api-frameworks/making-soap-requests/
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.
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.