2011-11-18 89 views
1

我目前正在开发一个WCF双工服务,我想实现的回调方法在我的客户端应用程序但有是如何解决执行回调方法时收到的错误?

'App.CallbackHandler' does not implement interface member IPostingServiceCallback.retrieveNotification(Service.Posting)' 

为我服务的服务合同的错误情况如下

[ServiceContract(SessionMode=SessionMode.Required , CallbackContract = typeof(IPostingServiceCallBack))] 
public interface IPostingService 
{ 
    [OperationContract(IsOneWay = true)] 
    void postNotification(Posting post); 
} 

public interface IPostingServiceCallBack 
{ 
    [OperationContract] 
    String retrieveNotification(Posting post); 
} 

我已生成代理并添加到我的客户端的项目文件中,并将端点地址添加到app.config中。

编辑

我在我的客户端应用程序的代码是目前

public class CallBackHandler : IPostingServiceCallback 
{ 
    public void retrieveNotification() 
    { 
     //planning to do something 
    } 
} 

回答

0

客户端应用程序需要实现IPostingServiceCallBack并定义retrieveNotification方法。

假设你有一个客户端(而不是代理),这将消耗你的双工服务:

public class MyClient : IPostingServiceCallBack 
{ 

    public String retrieveNotification(Posting post) 
    { 

     // Implement your logic here 
    } 
} 

注意上面是一个最基本的例子作为一个简单的例子。您的客户端可能也会从另一个类派生(取决于它是ASP.NET,WinForms,WPF等)。

更新

你还没有实现的方法。您的回调接口是:

public interface IPostingServiceCallBack 
{ 
    [OperationContract] 
    String retrieveNotification(Posting post); 
} 

你的实现是:

public class CallBackHandler : IPostingServiceCallback 
{ 
    public void retrieveNotification() 
    { 
     //planning to do something 
    } 
} 

你有public void retrieveNotification(),而接口有String retrieveNotification(Posting post)。方法签名不匹配。

你需要做的:

public class CallBackHandler : IPostingServiceCallback 
{ 
    public String retrieveNotification(Posting post) 
    { 
     // planning to do something 
    } 
} 
+0

嗨,这就是我目前在我的客户端应用程序。输入后它会出现上述错误。 – Thomas

+0

@Thomas - 我根据对原始问题的编辑更新了我的答案。 – Tim

+0

非常感谢! – Thomas

相关问题