简体   繁体   中英

Using interface in service contract instead of concrete type in WCF

I have WCF service operation which accepts Interface as a input type. 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". The jQuery code works file if the input type is concrete class. 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. Are you debugging the app when you make the call to the service using jQuery?

To get more information in the actual exception you should use svcTraceViewer. If you've not used svcTraceViewer before then you may want to look at a blog post on my blog

svcTraceViewer - Debugging WCF Sevices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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