I have been trying to pass an array/list of integers from Python to C# and I keep encountering the same error:
Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. '.
This is the C# code that I am trying to pass my list of integers to:
void SimpleSetFunction(int foo, List<int> bar);
In Python, I have tried to pass it in many ways and they have all failed, returning the previously stated error. Examples of what I have tried:
client.service.SimpleSetFunction(1,[0,1,2]) #fails
client.service.SimpleSetFunction(1,['0','1','2']) #fails
The only way I was able to pass a list to SimpleSetFunction was to call the SimpleGetFunction first, and then pass the result to SimpleSetFunction.
The SimpleGetFunction would return something like this:
(ArrayOfint)
{
int[] =
1,
2,
}
Which I could now pass to the Set function, like so:
foo = client.service.SimpleGetFunction()
client.service.SimpleGetFunction(1,foo) #works
The problem with such a thing, of course, is that I can only set something which is already there. I can't add any new integers to the list.
So, how do I pass the integers I want to the C# list?
Full Traceback:
Traceback (most recent call last):
File "<path>\SimpleGet.py", l
ine 228, in <module>
test_test()
File "<path>\SimpleGet.py", l
ine 81, in test_test
client.service.SimpleSetFunction(1,1)
File "<path>\client.py"
, line 542, in __call__
return client.invoke(args, kwargs)
File "<path>\client.py"
, line 602, in invoke
result = self.send(soapenv)
File "<path>\client.py"
, line 649, in send
result = self.failed(binding, e)
File "<path>\client.py"
, line 702, in failed
r, p = binding.get_fault(reply)
File "<path>\binding.py", line 265, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'The formatter threw an exception while tryi
ng to deserialize the message: There was an error while trying to deserialize pa
rameter http://tempuri.org/:channels. The InnerException message was 'Error in l
ine 1 position 351. Expecting state 'Element'.. Encountered 'Text' with name ''
, namespace ''. '. Please see InnerException for more details.'
SimpleGet.py:
import sys
import array
import time
from suds.client import Client
from array import array
def test_test():
wsdl = 'http://*<URL>*/*<URL>*?wsdl'
client = Client(wsdl)
result = client.service.IsAlive()
if result == "true":
print "Alive"
getResult = client.service.SimpleGetFunction(1)
setFunction = client.service.SimpleSetFunction(1,**????**)

List<int>toint[]and this will work.SimpleGet.py