1
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)

我想在下面调用获取联系人定义的简单方法

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

我相信我无法在这里正确传递参数。这就是形成错误请求的原因

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

在 WSDL 客户端中,我可以看到下面的代码来获取带参数的方法。

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)
4

1 回答 1

2

您正在尝试从 a 中解压缩关键字参数dict,并且需要为此使用**kwarg符号:

data = campaign_client.GetContact(**test)

查看此 Python 文档页面:解包参数列表

于 2015-04-30T07:18:26.790 回答