Fad*_*oof 7 .net web-services interface
我需要从webservice返回一个复杂类型,并构造了MyComplexType类,它实现了IMyComplexType接口.现在在我的webservice中,我有一个方法应该返回一个实现IMyComplexType的对象,如下所示:
[WebMethod]
public IMyComplexType GetMyComplexType()
{
IMyComplexType myCt = new MyComplexType();
...
return myCt;
}
Run Code Online (Sandbox Code Playgroud)
一切都编译好,但是当我运行webservice时,它会抛出一个异常,如下所示:
System.NotSupportedException: Cannot serialize interface MyWebService.IMyComplexType.
Run Code Online (Sandbox Code Playgroud)
这是设计还是我遗漏了一些东西.我可以以某种方式装饰我的类或界面以允许这个吗?我是否必须消除所有接口,并且只能使用具体的,也许是抽象的基类来使用.net webservices来实现这一点?
编辑:
这是我尝试序列化的接口:
public interface ICustomer
{
long Id {get; set;}
string Name {get; set;}
string EmailAddress {get; set;}
}
Run Code Online (Sandbox Code Playgroud)