问题
WCF noob here. I am exploring the online template in Visual Studio 2010: WCF REST Service Template 40
Does anyone know of a great sample to learn from? Or at least point me the right direction... I am trying to create a service of looking up a EmployeeID from a database to return some serialized employee profile data.
Basically, I wish to know what goes where (via the newer way, WCF 4.0, RESTful, Json). -ConnectionString -QueryString -etc
Hoping the Url will look something like this: http://localhost:55123/EmployeeService/EmployeeLookup/{EmployeeID}
My next task of course would be to consume the service in some webpage.
Thank you in advance for the guidance.
回答1:
Watch this video:
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/MID307
It gives you exactly the overview you are looking for and has accompanying code samples.
回答2:
I just went through this 10 part sample this weekend (it's supposed to be 12, but they never posted the last 2). It uses a database to retrieve task and user info, and might give you a feel for what you're trying to do.
I found it very useful and informative, and I've been doing SOAP WCF (3.5) for the last year+.
Introducing WCF WebHttp Services in .NET 4
The 10 parts posted so far are:
1. Getting Started with WCF WebHttp Services in .NET 4 2. Clients and the Automatic Help Page in WCF WebHttp Services 3. Updating State in WCF WebHttp Services 4. Automatic and Explicit Format Selection in WCF WebHttp Services 5. Error Handling in WCF WebHttp Services with WebFaultException 6. Using Routes to Compose WCF WebHttp Services 7. Integrating ASP.NET Output Caching with WCF WebHttp Services 8. Returning Custom Formats from WCF WebHttp Services 9. Creating Views in WCF WebHttp Services with T4 10. Conditional GET and ETag Support in WCF WebHttp Services
The first 4 will probably be of the most interest to you based on the question, but all 10 are valuable and informative.
来源:https://stackoverflow.com/questions/7304104/wcf-rest-service-template-40-cs-sample-with-data-access