Python 官方文档:入门教程 => 点击学习
实现目标: 1.创建一个WCF服务,用于读卡。 再创建一个winform客户端程序,作为WCF的宿主。 WCF服务以 IP+端口的形式对外提供服务。 2.python中安装suds,用于解析 WCF的服务地址。 winfO
实现目标:
1.创建一个WCF服务,用于读卡。 再创建一个winform客户端程序,作为WCF的宿主。 WCF服务以 IP+端口的形式对外提供服务。
2.python中安装suds,用于解析 WCF的服务地址。
winfORM客户端程序中的主要代码:
ServiceHost Host = new ServiceHost(typeof(WcfTest.Service1));
//绑定
System.ServiceModel.Channels.Binding HttpBinding = new BasicHttpBinding();
//终结点
Host.AddServiceEndpoint(typeof(WcfTest.IService1), httpBinding, "http://localhost:8002/");
if (Host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>() == null)
{
//行为
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
//元数据地址
behavior.HttpGetUrl = new Uri("http://localhost:8002/Service1");
Host.Description.Behaviors.Add(behavior);
//启动
Host.Open();
}
Python程序中的调用代码:
from suds.client import Client
def getDataTest(cu):
try:
client = Client(‘http://localhost:8002/Service1‘)
print client #结果看图1
result = client.service.ShowMess() #这个号码是办证的,拿来测试,哈哈
return JSONResponse(result)
except:
return jsONResponse(‘error’)
--结束END--
本文标题: python调用wcf服务 实现网
本文链接: https://www.lsjlt.com/news/185313.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0