What is the difference between developing WCF service by opening a console application project(generally) and a WCF project? By creating a WCF service project, the auto generated files consist of app_data, IService1.cs , Service1.svc and web.config. What is the purpose of those files?
thanks!
a WCF service project is a web project designed to run in IIS.
The web.config file contains the configuration of the web app (and the WCF service configuration -endpoint, behaviors, bindings)
The svc file is the web resource your client will call, it associates an url (service1.svc) with a service contract.
The IService1.cs file contains the service contract interface.
there is a Service.svc.cs file too which contains the service contract implementation.
If you use WCF in a console project, you will have to start WCF yourself (ServiceHost etc...)
If you use WCF in a web application, this logic is handled by the service activation framework in IIS, using the configuration provided by web.config.
IIS activated WCF services are easier to use, but require to be hosted by the web server.
Related
I have a silverlight application and uses wcf ria services. The question is about the options to host the wcf ria services.
In all the articles I read says, the RIA services should be hosted on the same web application where the silverlight app is hosted.
An alternative is , we can use WCF RIA class library, but still this need to be referenced in the silverlight web app where the silverlight is hosted.
I am wondering , for a cleaner implementation , can I host the WCF RIA services in any other web apps?
The default scenario for WCF RIA Services assumes that you will create your business objects to be shared between the server and the client within your web project, and these will be replicated within your Silverlight project.
However, this scenario doesn't create an ideal separate “middle tier” where your business objects are contained within a separate assembly that can then be reused between applications.
This is where the WCF RIA Services Class Library project template comes in. It is possible, however, to move the business logic out of the Web project and into a separate class
library, using the WCF RIA Services Class Library project template. So you can have your entities and metadata classes in a separate project from your server project. But you must add a reference to it in your web project where the silverlight is hosted.
This is a reasonable thing
How would I host 2 WCF services within the same web site ( i.e. same web application) ? I do not want to have each WCF with its own independent web site host.
WCF Services integration with IIS uses a .svc file for hosting in a web application.
You can create as many .svc files as services you created with WCF in the same web application, so you only need to create a .svc file for each WCF service inside your web project.
Maybe you could explain the implementation details services to know if this applies to you.
Does anyone know how to host a WCF Data Service (or OData) inside IIS7? I'm seeing lots of articles about hosting WCF, but none specific to WCF Data Service.
Thank you very much.
Hosting a WCF Data Service in IIS is actually the default option.
Its a pretty easy 3 step process:
Create a new WebApplication project (or re-use an existing one)
Add a WCF Data Service to the project
Deploy to your IIS server
Step 3 is just the standard process for deploying a WebApplication to IIS.
A WCF Data Service is just a WCF (REST) service, with some additional out-of-the-box functionality added in.
It has a *.svc file and all - it will be hosted very much the same as a "regular" WCF REST service.
So all the articles you see about WCF REST should really apply to WCF Data Services as well - or are you experiencing some difficulties with something specifically??
I currently have a website where I'm hosting a webservice with several web methods, I need to add some new web methods, but I want to move to the WCF services model rather than continue with asmx. I want to be able to host the WCF service in the same IIS 6 website as the asmx is - is this possible and if so are there any gotchas?
You could host the WCF service in a virtual directory under the one holding the ASMX service. You will have to make the new virtual directory be an application, so it can have its own bin folder.
BTW, you distinguish "web services" from "WCF services". This is a false distinction. WCF is the replacement for the legacy ASMX technology, and can do both plain SOAP like ASMX services, or just about anything else.
I am developing a WCF web service and I used the WCF Service Application template to do that.
Does creating a "WCF Service Application" fulfill this requirement?
What are the advantage of creating a WCF Service Library over a WCF Service Application?
A service application includes a website host already setup for you. A service library is a library of services that a host can reference and startup.
If you start with a service library (recommended) you can then choose any host you wish (a windows service, IIS/ASP.NET, or even a console application) and you'd just reference your library from your new host. Choosing a Service Application limits your host to just IIS/ASP.NET (though this might be ok for your purposes, but will limit the protocols you can use).
Edit: Changes in IIS since I wrote this allow for a wider variety of protocols on ASP.NET activated services, so choosing a service application is much less limiting than before.
If all you have is the one project I see only added complexity if you separate for the heck of it. I used a library when I had some particular use cases where I had to host in both a windows service and in IIS.
For IIS you you can move the classes and interfaces to a library but keep your .SVC files in the web project. You must edit the .SVC files to point to the properly qualified classes.