0

Watching some videos they talk about endpoints and im not sure what the differences are in base address and endpoints when it comes to wcf RESTful services?

Why when using rest do you declare the URLs in the Contract areas? I mean whats the difference between wcf and restful wcf? Taking a guess is it WCF as a standalone you use the entire service at once or it serves one person at a time? And restful can service many unique and different client side applications/solutions at any given time? Dont really get the difference between wcf and restful wcf?

If I create a solution wcf service library and a "host" programme say a console app that allows post get and delete etc then I create another application and add the service reference of the first soultions service library I should then be able to retrieve data and post data etc. Thats fine. But what on earth does rest do to the service that makes it any different?

Kirsty White
  • 1,210
  • 3
  • 26
  • 54

1 Answers1

2

So does that mean you have to create the host, how would you do that?

By using an instance of the ServiceHost class, if you're doing this in code like in a windows app or service you follow this format:

 var host = new ServiceHost(typeof(ServiceClassToHost));
 host.Open();

Also how do you define this service is it just in the web.config file, do you declare the url and port number? Because watching some videos they talk about endpoints and im not sure what the differences are in base address and endpoints when it comes to REST?

a good answer to the baseaddress question:

WCF service configuration file question regarding <baseAddresses>

As you have guessed, the baseAddresses element is completely ignored when hosting in IIS. The service's base address is determined by the web site & virtual directory into which your wcf service is placed. Even when self-hosting, baseAddresses is not required. It is merely a convenience that avoids you having to enter a full address for each endpoint. If it is present, the endpoints can have relative addresses (relative to the base address, that is).

From there presumably when im making a client side application or a consumable web app I just type the url of the web server hosting the service lib via the "add service reference" when trying to add the service to the solution, and then I should be able to transfer data freely to and from the server?

If you want inside VS to add a service reference, what this does is create the proxy you need to work with as a client, the other route is handrolling your own proxy, or using svcutil.exe to generate the proxy from the command line.

I can't answer the REST questions, sorry. ;)

Community
  • 1
  • 1
Mark W
  • 3,879
  • 2
  • 37
  • 53
  • Thank you mark for answering, I’m sorry I had to re-edit my question as it was over generalized but your answer is still relevant! – Kirsty White Mar 23 '12 at 15:28