Skip to content

Instantly share code, notes, and snippets.

@amirasaran
Created December 13, 2016 07:09
Show Gist options
  • Save amirasaran/9ee4763daa644a63c29638a041a007a1 to your computer and use it in GitHub Desktop.
Save amirasaran/9ee4763daa644a63c29638a041a007a1 to your computer and use it in GitHub Desktop.
simple soap client for python
from zeep import helpers, Client
import types
class SoapConnector(object):
def __init__(self, base_url):
self._client = Client(base_url)
def send(self, method, data):
connector = getattr(self._client.service, method)
result = connector(**data)
return helpers.serialize_object(result) \
if isinstance(result, types.ListType) or isinstance(result, types.ClassType) else result
client = SoapConnector("http://www.webservicex.net/ConvertSpeed.asmx?WSDL")
data = {
"speed": "100",
"FromUnit": "kilometersPerhour",
"ToUnit": "milesPerhour"
}
result = client.send('ConvertSpeed', data)
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment