当前行为
我试图请求python中的WCF服务(绑定是wsHttpBinding)。然而,无论是使用肥皂水还是zeep,我都失败了。 当使用SOAP客户端(如SOAP UI)时,它也会失败。 我做到这一点的唯一方法是从VisualStudioWCF客户端或通过C#代码调用它
Python泡沫
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')
pythonzeep
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);
}
->;服务将正确地返回结果
预期行为
像在C#中一样,在python中正确地获得结果
提前谢谢你的帮助
目前没有回答
相关问题 更多 >
编程相关推荐