C# WCF合同继承合同
我正在用WCF键入一个应用程序,并试图定义一个回调 与从另一个接口派生的接口签订合同。 这样,生成的代理代码(使用svcutil.exe)就看不到基代码 接口,并在尝试时在服务器上引发“NotSupportedException” 调用基接口中定义的方法C# WCF合同继承合同,c#,.net,wcf,C#,.net,Wcf,我正在用WCF键入一个应用程序,并试图定义一个回调 与从另一个接口派生的接口签订合同。 这样,生成的代理代码(使用svcutil.exe)就看不到基代码 接口,并在尝试时在服务器上引发“NotSupportedException” 调用基接口中定义的方法 [ServiceContract] public interface ITestCallback : IPing { [OperationContract] void TestCB (); } 我还尝试在代理类中手动定义基接口
[ServiceContract]
public interface ITestCallback : IPing
{
[OperationContract]
void TestCB ();
}
我还尝试在代理类中手动定义基接口
以便能够在客户端->相同的行为中实现这些方法
有人知道它为什么不起作用吗
谢谢你的帮助,很抱歉再次发布
以下是我的合同定义:
namespace wcfContract
{
[ServiceContract(Namespace = "Test")]
public interface IPing
{
[OperationContract]
void Ping();
}
public interface ITestCallback : IPing
//<-------------- IPing method not seen at all in proxy
{
[OperationContract]
void TestCB();
}
[ServiceContract(Namespace = "Test", CallbackContract =
typeof(ITestCallback))]
public interface ITest : IPing
{
[OperationContract]
void Test();
}
}
名称空间wcfContract
{
[ServiceContract(Namespace=“Test”)]
公共接口IPing
{
[经营合同]
无效Ping();
}
公共接口ITestCallback:IPing
// 您是否尝试将[ServiceContract]标记添加到ITestCallback?您需要将[ServiceContract]属性添加到ITestCallback接口
[ServiceContract]
public interface ITestCallback : IPing
{
[OperationContract]
void TestCB ();
}
服务类需要继承派生契约(即ITestCallback)
Web.config文件中相应的端点绑定需要指定正确的约定(如下面“ws”的端点地址)
我没有使用svcutil,我只是通过在项目中添加服务引用来引用
<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>