6
我想传递一个列表(或阵列,集合)的WCF服务端点从蟒蛇传递Python列表为字符串的WCF服务
的WCF接口:
[OperationContract]
string[] TestList(IEnumerable<string> vals);
绑定在Web.config中:
<endpoint address="http://localhost:13952/Service/Endpoint.svc" binding="basicHttpBinding" contract="Service.IEndpoint">
Python代码调用SER副:
from suds.client import Client
url = 'http://localhost:13952/Service/Endpoint.svc?wsdl'
client = Client(url)
result = client.service.TestList(('a', 'b', 'c'))
产生的错误:
suds.WebFault: Server raised fault: 'The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:vals. The InnerException message was 'Error in line 1 position 310. Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. '. Please see InnerException for more details.'
我将尝试使用Wireshark来捕捉数据包并试图从那里来调试。希望有人知道这个简单的解决方案。
谢谢。
我不熟悉suds或python,但是从错误消息看起来好像您已经发送命名空间信息作为您的soap消息的一部分,tempuri是自asmx天后的默认命名空间服务微软堆栈 – kd7
我对python也不熟悉,但是“Expecting state'Element'..遇到'Text'”意味着字符串数组没有以WCF期望的格式序列化。看到类似的问题[这里](http://stackoverflow.com/questions/5219505/invoking-a-wcf-method-that-takes-a-list-of-objects-consumed-via-an-iphone-applic)和[这里](http://social.msdn.microsoft.com/Forums/en/wcf/thread/fae9dbc5-c83e-42b2-808e-1a393e621bb8)。 – Kimberly