码迷,mamicode.com
首页 > 其他好文 > 详细

具有 ServiceContractAttribute 特性

时间:2015-08-03 10:07:39      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

协定类型 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初始化的时候,需要指定的接口

具有 ServiceContractAttribute 特性

标签:

原文地址:http://www.cnblogs.com/chucklu/p/4698562.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!