协定类型 ZBMService.QueryHistoryData 不具有 ServiceContractAttribute 特性。
若要定义有效协定,指定的类型(协定接口或服务类)必须具有 ServiceContractAttribute 特性。

 

Uri TradeServiceUriBase = new Uri("http://" + myName + ":8000/QueryHistoryData");

//Create a ServiceHost for the Orderprocessor service.
Type serviceType = typeof(QueryHistoryData);
ServiceHost host = new ServiceHost(serviceType, TradeServiceUriBase);

 

BasicHttpBinding httpBinding = new BasicHttpBinding();

host.AddServiceEndpoint(typeof(QueryHistoryData), httpBinding, "");

 

问题出在添加终结点的地方:

需要修改为

BasicHttpBinding httpBinding = new BasicHttpBinding();

host.AddServiceEndpoint(typeof(IQueryHistoryData), httpBinding, "");

 

ServiceHost初始化的时候,需要指定服务类型,使用的是类

但是EndPoint初始化的时候,需要指定的接口

相关文章:

  • 2021-10-27
  • 2022-01-20
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-06-24
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
相关资源
相似解决方案