Created
December 13, 2016 07:09
-
-
Save amirasaran/9ee4763daa644a63c29638a041a007a1 to your computer and use it in GitHub Desktop.
simple soap client for python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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