0

How can I consume a WCF Data Service without adding a Service Reference.

For a normal WCF service, we use shared contracts and create proxy at runtime to call the service. Is similar concept possible in case of Data Service?

Shikhar
  • 43
  • 1
  • 8
  • 1
    Publish WCF Service to the server, Get the URL and test it in the browser if it's returning data in XML/JSON format, then Use that URL in your program(C#) to fetch the data using HttpRequest etc... if you want to consume it in JavaScript then use ajax request. – Muhammad Imran Jul 19 '15 at 05:00
  • @Muhammadimran Thank you for your comment..! Is there any other way similar to what we do for WCF using channel ? – Shikhar Jul 19 '15 at 16:48
  • Channel seems not a good option; it needs access to your assemblies. Creating and using proxy is a good option rather. see following links: http://stackoverflow.com/questions/2308876/direct-channel-usage-vs-using-a-proxy and http://stackoverflow.com/questions/1698275/wcf-channelfactory-vs-generating-proxy – Muhammad Imran Jul 19 '15 at 17:11
  • @Muhammadimran - Proxy is definately a better option. Thank you..!! Also, I was wondering if we can expose DTO classes instead of actual entities with Data Service?? – Shikhar Jul 19 '15 at 17:16
  • In this case you've to write custom provider. Auto generated ones are recommended though. – Muhammad Imran Jul 19 '15 at 17:22

0 Answers0