Вам необходимо использовать клиентскую фабрику Suds.
Итак, важная часть, которую вы упускаете, это client.factory.create('ArrayOfString')
.
См. Модульный тест ниже:
#!/usr/bin/env python
import unittest
import suds
from suds.client import Client
class TestCSharpWebService(unittest.TestCase):
def setUp(self):
url = "http://localhost:8080/WebService.asmx?wsdl=0"
self.client = Client(url)
def test_service_definition(self):
# You can print client to see service definition.
self.assertTrue("orderAlphabetically" in self.client.__str__())
self.assertTrue("ArrayOfString" in self.client.__str__())
def test_orderAlphabetically_service(self):
# Instanciate your type using the factory and use it.
ArrayOfString = self.client.factory.create('ArrayOfString')
ArrayOfString.string = ['foo', 'bar', 'foobar', 'a', 'b', 'z']
result = self.client.service.orderAlphabetically(ArrayOfString)
# The result list contains suds.sax.text.Text which acts like a string.
self.assertEqual(
type(result.string[0]),
suds.sax.text.Text)
self.assertEqual(
[str(x) for x in result.string],
['a', 'b', 'bar', 'foo', 'foobar', 'z'])
if __name__ == '__main__':
unittest.main()
Я запустил веб-сервис в MonoDevelop 3 и Mono 2.10.
namespace WebServiceMono
{
using System.Linq;
using System.Web.Services;
using System.Collections.Generic;
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string[] orderAlphabetically (List<string> list)
{
var result = list.OrderBy (s => s);
return result.ToArray ();
}
}
}