How to pass value to method of wsdl client using pysimplesoap

1.5k views Asked by At
from pysimplesoap.client import SoapClient
client = SoapClient(wsdl="https://platform.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc?wsdl")
auth_token = client.ClientLogin(username = 'user', password = 'pass',
                                 applicationKey = 'test')

#I got authenticated here

token=  auth_token['ClientLoginResult']

campaign_client =  SoapClient(wsdl="https://platform.mediamind.com/Eyeblaster.MediaMind.API/V2/CampaignService.svc?wsdl"
                                  ,trace = False)

There is simple method I want to call get contact definition below

Show    
    Parameters  

    Name    Type    Description
    ContactID   Int32   The contact ID. Mandatory field.
    UserSecurityToken   String  Contains a string that uniquely identifies the current Sizmek Trafficking API session. You may retrieve the token after logging into the AuthenticationService

_

Show    
Response    

Name    Type    Description
Contact     ContactInfo     Returns the contact information used by ContactInfo

I believe I am not able to pass parameters correctly here. That's why wrong request is formed

test = {'UserSecurityToken' :token,'ContactID' : 1  }
data = campaign_client.GetContact(test )

In WSDL client I can see the code below to get method with parameters.

def __getattr__(self, attr):
        """Return a pseudo-method that can be called"""
        if not self.services:  # not using WSDL?
            return lambda self=self, *args, **kwargs: self.call(attr, *args, **kwargs)
        else:  # using WSDL:
            return lambda *args, **kwargs: self.wsdl_call(attr, *args, **kwargs)
1

There are 1 answers

8
bosnjak On

You are trying to unpack keyword arguments from a dict, and you need to use **kwarg notation for that:

data = campaign_client.GetContact(**test)

Checkout this Python docs page: Unpacking Argument Lists