Dan Revell Dan Revell - 1 year ago 72
C# Question

Add service reference to ASP.NET Web API service

I've got an MVC solution that hosts a few routes for Web API services. In some situations, I will call these from JavaScript with a simple HTTP get. In others, I want to call them from some .NET code, perhaps another MVC application.

Is there a way to add a service reference to these Web API endpoints and have the tooling create the proxy client and CLR types as it would do with a typical WCF service? I know there is no SOAP involved here but I did read that it is possible, just not how.

Answer Source

No it is REST service. REST service doesn't expose metadata for creating proxy by service reference (except WCF Data Services which have some special form of metadata). Use Web-API's HttpClient class to call the service.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download