如何在zeep客户端发送参数

时间:2022-11-23 08:40:41

hey guys I am using python zeep library and I am trying to send a request to a soap client but I keep getting this error

嘿家伙我正在使用python zeep库,我正在尝试向soap客户端发送请求,但我一直收到此错误

ValueError: The String type doesn't accept collections as value

ValueError:String类型不接受集合作为值

this is the XML file of the WSDL client:

这是WSDL客户端的XML文件:

<s:element name="SendSms">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="to" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="from" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="text" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="isflash" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="udh" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="recId" type="tns:ArrayOfLong"/>
<s:element minOccurs="0" maxOccurs="1" name="status" type="s:base64Binary"/>
</s:sequence>
</s:complexType>
</s:element>

and here is my code:

这是我的代码:

from zeep import Client


client = Client("http://www.parandsms.ir/post/send.asmx?wsdl")
parameters = {
    "username":"my_user_name",
    "password":"my_password",
    "from":"50009666096096",
    "to":"a_phone_number_wich_i_put_here_as_string",
    "text":"salam",
    "isflash":False,
    'recId':"",

}
res = Client
status = 0
status= client.service.SendSms(parameters).SendSmsResult()
print(status)

I have been stuck at this error for a long time

我已经被这个错误困住了很长时间

if somebody could help I would really appreciate it

如果有人可以提供帮助,我会非常感激

thanks

谢谢

1 个解决方案

#1


0  

Pass them as named parameters to your service method:

将它们作为命名参数传递给您的服务方法:

result = client.service.SendSms(username='my_user_name', password='my_password', ...)

or since you have many parameters and they're a dict already:

或者因为你有很多参数并且它们已经是一个字典:

result = client.service.SendSms(**parameters)

#1


0  

Pass them as named parameters to your service method:

将它们作为命名参数传递给您的服务方法:

result = client.service.SendSms(username='my_user_name', password='my_password', ...)

or since you have many parameters and they're a dict already:

或者因为你有很多参数并且它们已经是一个字典:

result = client.service.SendSms(**parameters)