In [5]:
from suds.client import Client

In [9]:
url = 'http://10.192.224.5:7006/CommonServices_SB/ProxyService/GetMSISDNProfileProxy?wsdl'
client = Client(url)

In [10]:
def GenerateMethods(client):
    methodInputList = []
    methodInputDict = {}


    for method in client.wsdl.services[0].ports[0].methods.values():
        methodInputDict["name"]= str(method.name)
        #methodInputDict["inputs"]=[]
        for part in method.soap.input.body.parts:
            methodInputDict["inputs"]={}
            for k,v in client.factory.create(part.element[0]):
                methodInputDict["inputs"][k]=v
                
        #print '%s(%s)' % (method.name, ', '.join('%s' % (client.factory.create(part.element[0])) for part in method.soap.input.body.parts))
        #print "\n\n\n\n"
        methodInputList.append(methodInputDict)
        methodInputDict = {}
    return methodInputList
    
    

methods =  GenerateMethods(client)  

for method in methods:
    print method['name'],method['inputs']
    #print "Method: %s , Input %s"%(method["name"],method["inputs"])


GetMSISDNProfile {MSISDN: None}

In [8]:
import sys
import json
print json.dumps(methods)
tmp = methods[0]['inputs']
tmp['MSISDN']='96565000570'
methods[0]['inputs']  = tmp

for method in methods:
    try:
        print getattr(client.service,method['name'])(**method['inputs'])
    except:
        e = sys.exc_info()[0]
        print e


ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://osb.wataniya.com/GetMSISDNProfileWSDL/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:GetMSISDNProfile>
         <MSISDN>96565000570</MSISDN>
      </ns1:GetMSISDNProfile>
   </ns0:Body>
</SOAP-ENV:Envelope>
[{"inputs": {"MSISDN": null}, "name": "GetMSISDNProfile"}]
<class 'suds.WebFault'>

In [247]:
tmp = methods[1]['inputs']
tmp['Year']='2014'
tmp['Month']='9'
methods[1]['inputs']  = tmp

print methods[1]['inputs']

getattr(client.service,methods[1]['name'])(**methods[1]['inputs'])


{Year: '2014', Month: '9'}
Out[247]:


In [4]:
from SoapProxy import models


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-d5a78648875d> in <module>()
----> 1 from SoapProxy import models

ImportError: No module named SoapProxy

In [3]:


In [ ]: