简体   繁体   English

在服务合同中使用接口代替WCF中的具体类型

[英]Using interface in service contract instead of concrete type in WCF

I have WCF service operation which accepts Interface as a input type. 我有WCF服务操作,它接受接口作为输入类型。 While calling this service operation from jQuery Ajax, I'm getting message "The server was unable to process the request due to an internal error". 从jQuery Ajax调用此服务操作时,我收到消息“由于内部错误,服务器无法处理请求”。 The jQuery code works file if the input type is concrete class. 如果输入类型是具体类,则jQuery代码工作文件。 Please tell me if there is any way to achieve this kind of implementation. 请告诉我是否有任何方法可以实现这种实现。

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]    
public class TestService
{
    [OperationContract]
    [ServiceKnownType(typeof(User))]
    public void SetUser(IUser request)
    {
    }
}

This is possible in WCF, so the question is what is the real exception message. 在WCF中这是可能的,所以问题是什么才是真正的异常消息。 Are you debugging the app when you make the call to the service using jQuery? 使用jQuery调用服务时,是否正在调试应用程序?

To get more information in the actual exception you should use svcTraceViewer. 要获得实际异常中的更多信息,您应该使用svcTraceViewer。 If you've not used svcTraceViewer before then you may want to look at a blog post on my blog 如果您之前没有使用过svcTraceViewer,那么您可能需要查看我博客上的博客文章

svcTraceViewer - Debugging WCF Sevices svcTraceViewer - 调试WCF服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM