为什么不能在我的WCF客户端操作我拿合同接口,参数? [英] Why can't my operation contracts in my wcf client take interfaces as parameters?

查看:168
本文介绍了为什么不能在我的WCF客户端操作我拿合同接口,参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的WCF服务合同,如果我使用的具体实现的接口工作正常,但如果我想使用的接口在PARAMATERS,而不是具体的类,它给了我,我将在下面显示错误

I have a simple wcf Service Contract that works fine if I use the concrete implementations for the interfaces, but if I want to use the interfaces in the paramaters instead of the concrete classes, it gives me the error which I will display below.

下面是代码:

[ServiceContract]
public interface IClientUserRegistration
{
    [OperationContract]
    void RegisterClientUser(ClientUser clientUser);

    [OperationContract]
    List<ClientUser> GetUsers();
}

如果我IClientUser取代ClientUser,WCF测试客户端说,RegisterClientUser $ B不支持$ b的操作,因为它使用的System.Object类型。如果我更换名单GetUsers的返回值,它说,不支持此操作,因为它使用System.Object类型[]。为什么它给这些错误?

If I replace ClientUser with IClientUser, the WCF Test Client says that RegisterClientUser operation is not supported because it uses the type System.Object. If I replace the return value of GetUsers with List, it says that this operation is not supported because it uses the type System.Object[]. Why does it give these errors?

为什么我试图用IClientUser的是,我可以实现实现了IClientUser接口,并将其传递到RegisterClient不同的用户类型的原因,但如果我只能够通过ClientUser,那么我必须创建一个一堆采取不同类型的用户RegisterClient覆盖的。

The reason why I was trying to use IClientUser is that I could implement different user types that implement the IClientUser interface and pass them into RegisterClient, but if I am only able to pass ClientUser, then I have to create a bunch of RegisterClient overrides that take different types of Users.

推荐答案

SOAP没有接口的概念。这就往往使反序列化困难。

SOAP has no concept of interfaces. That would tend to make deserialization difficult.

这篇关于为什么不能在我的WCF客户端操作我拿合同接口,参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆