current behavior
I am trying to request a WCF service in python (binding is wsHttpBinding). However I am failing either using suds or zeep. It also failing when using a SOAP client like SOAP UI. The only way I manage to do it is to invoke it from Visual Studio WCF client or via C# code.
Python Suds
from suds.client import Client
import datetime
print("Connecting to Service...")
wsdl = "http://server_name/services/CdsSpread/CdsSpread.svc?wsdl"
client = Client(wsdl, headers={'Content-Type': 'application/soap+xml;charset=UTF-8'})
result = client.service.GetCounterpartiesInfo(datetime.datetime(2020, 11, 5), ['TOTO', 'TATA'])
print(result)
->
Exception: (400, 'Bad Request')
Python Zeep
from zeep import Client, Settings
import datetime
settings = Settings(strict=False, xml_huge_tree=True)
wsdl = r'http://server_name/services/CdsSpread/CdsSpread.svc?wsdl'
client = Client(wsdl=wsdl, settings=settings)
array_of_string = client.get_type('ns2:ArrayOfstring')
array = array_of_string(['TOTO', 'TATA'])
result = client.service.GetCounterpartiesInfo(asOfDate=datetime.datetime(2020, 11, 5), counterparties=array)
print(result)
->
zeep.exceptions.Fault: The message could not be processed. This is most likely because the action 'http://tempuri.org/ICdsSpread/GetCounterpartiesInfo' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
C#
static void Main(string[] args)
{
var f = new ServiceReference1.CdsSpreadClient();
var e = f.GetCounterpartiesInfo(DateTime.Today.AddDays(-4), new[] { "TOTO", "TATA" });
Console.Write(e);
}
-> the result is properly sent back by the service
expected behavior
Get the result properly in python like we do in C#
Thanks in advance for your help