无法从客户机调用wcf服务



报错"系统。InvalidOperationException: '试图获取ITC2DataService的合同类型,'但该类型不是ServiceContract,也没有继承ServiceContract."

注意:我已经装饰了接口"ITC2DataService"与"ServiceContract"属性。但是仍然出现错误

除了将ServiceContract添加到ITC2DataService之外,服务类还继承派生契约,例如:

public class Service1 : ITC2DataService
{
...
}

Web中相应的端点绑定。配置文件需要指定正确的契约(比如端点地址" was ")下文)。

<services>
<service name="WcfService.Service1" behaviorConfiguration="WcfService.Service1Behavior">
<!-- ITestCallback needs to be the contract specified -->
<endpoint address="ws" binding="wsHttpBinding" contract="WcfService.ITestCallback">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>

最新更新