I am using python zeep library and I am trying to send a request to a soap client, but I keep getting this error:
ValueError: The String type doesn't accept collections as value
This is the XML file of the WSDL client:
<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.
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)