Created
April 30, 2015 00:13
-
-
Save orther/0c21d74faadfe7dd6edc to your computer and use it in GitHub Desktop.
Basic test of SOAPpy connection to SiteLink's API (NOTE: I threw this together after soap2py failed on diffgram)
This file contains hidden or 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 SOAPpy import WSDL | |
SITELINK_URL = "https://api.smdservers.net/CCWs_3.5/CallCenterWs.asmx?WSDL" | |
SITELINK_CORP_CODE = "CCTST" | |
SITELINK_LOC_CODE = "Demo" | |
SITELINK_CORP_LOGIN = "Administrator" | |
SITELINK_CORP_PASS = "Demo" | |
SITE_INFORMATION_PARAMS = { | |
"sCorpCode": SITELINK_CORP_CODE, | |
"sLocationCode": SITELINK_LOC_CODE, | |
"sCorpUserName": SITELINK_CORP_LOGIN, | |
"sCorpPassword": SITELINK_CORP_PASS, | |
} | |
class SiteLinkSOAPClient(object): | |
def __init__(self): | |
self.server = WSDL.Proxy(SITELINK_URL) | |
def _parse_results(self, results): | |
rt = results[1].NewDataSet.RT | |
if "Ret_Code" in dir(rt): | |
if int(rt.Ret_Code) < 0: | |
return dict(Ret_Code=rt.Ret_Code, Ret_Msg=rt.Ret_Msg) | |
return results[1].NewDataSet.RT | |
def callMethod(self, name, **args): | |
return self._parse_results(getattr(self.server, name)(**args)) | |
def getMethods(self): | |
return self.server.methods.keys() | |
print "-- Parse WSDL" | |
slsc = SiteLinkSOAPClient() | |
print "== Available Methods (first 5):" | |
for m in slsc.getMethods()[:5]: | |
print " ", m | |
print "-- Call SiteInformation" | |
response = slsc.callMethod("SiteInformation", **SITE_INFORMATION_PARAMS) | |
print "== Return value from 'SiteInformation' call:" | |
print response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment