Combining WCF Service Library and WCF Service Application - c#

Thanks to Stack Overflow and a few other sites, I understand the difference between the WCF LIbrary and WCF Service Application templates.
Briefly the Library is a DLL that allows for multiple types of hosting. It does not have a .svc file. While the Service Applications template is created specifically with IIS in mine with a .svc file.
I read that WCF Service Library is the best way because it is the most flexible. But I NEVER see instructions on how to do it apart from using the WCF Service Application template.
Is it difficult to go from WCF Service Library to hosting on IIS from scratch? I have two books on WCF and I've read numerous articles and none of them cover how to create a svc file using only the WCF Service Library and No WCF Service Application. Why?
Nigel Shaw also mentions on the following link that there are limitations to using the Library option. What is the purpose of WCF Service Library?
Basically What I want to do is host the WCF Service on both IIS and a Windows Service. Thus it appears that the combined way is the best way. Nevertheless, I'm trying to learn why there aren't more instructions on using the WCF Service Library.
Ok, I did find a couple of articles that seem to use an ASP.NET Web Application and tells you how to create a text file for the svc file.
This article: http://debugmode.net/2010/12/25/wcf-service-library-creating-hosting-and-consuming-wcf-service-with-wcf-service-library-project-template/
and this one: http://danielvanwyk.wordpress.com/2010/04/30/create-host-and-consume-a-wcf-service-using-the-wcf-service-library-template-in-visual-studio-2008/
But what I still don't understand is why is the ASP.NET Application still needed? And If i add a svc file does it get placed in the wwwroot directory (that seems to be where the WCF Service Application places it .svc file?
Thanks!

A WCF Service Library has to be hosted in order to be used - you can host it in IIS, a Windows Service or some self-hosted option (like a console app, WinForm, WPF, etc).
In the last two links you provide, they're demonstrating how to host the library in an ASP.NET service application, but you don't have to use that project template to host it. It's simply one option out of several.
You can create an IIS-hosted implementation of your class library without using a VS project template, but you'll need to manually add the .svc file and the Web.config. I have done this several times:
Create a folder (I normally put mine in the wwwroot folder of inetpub, but you can put it wherever you desire).
Create a bin folder in the folder you created in step 1, and put the WCF service library and any other required assemblies in it.
Add a .svc file with the appropriate markup in the folder created in step 1.
Add a Web.config with the appropriate service model configuration in the folder created in step 1.
Create an application in IIS that points to the folder you created.
Now you have an IIS-hosted instance of your service. You can then use another copy of the WCF service library for your Windows-Service hosted instance.

Related

including a WCF service project in my website solution and referencing it

Im new to .net and I have my website solution and I added my database WCF service to the solution, how can i reference the service's interfaces? I will be making changes to the service as i develop, do I have to build/Deploy the service every time or can i just reference the .svc file somehow?
[nkvu - moving out of the comments & as an answer in case it needs to be found later...]
If your WCF service is a separate project in the same solution as your web project then you should be able to follow the instructions here under the "To add a reference to a service in the current solution" heading...After you make changes you can just use the instructions under "Update a Service Reference" to make sure your web project is in sync with the service changes

Use WCF class library in application

I am new to WCF and I don't really understand the puropose of a WCF class library. (it does not look like a library to me it launches a program when I run my application) I have created a WPF application with a reference to my WCF service library. Everything works great under development. When I launch my application from visual studio the service get's hosted automatically by visual studio.
Now let's say I am ready to deploy. If I launch the application from outside visual studio then the service will not run. How do I start the service?
WCF service class cannot exist in a void. You need to host and there are a couple of option for Hosting.
In Visual Studio, there was two main template for WCF, WCF Service Application and WCF Service Library. Depend on your need, choose which template will be good for your project. If you want Self Hosting, better choose WCF Service Library template. (You need to write Hosting Service/Application). If you want to Host in IIS, better choose WCF Service Application.
And check this Tutorial for self hosting.
http://wcftutorial.net/WCF-Self-Hosting.aspx

wcf service application deploying issue

I am new to wcf. I have developped a wcf service application(not a library). Can someone tell me how to deploy it other than iis. And how to access the service as a webservice. is this possible and how?
This link has an example that shows how to deploy a WCF-service as a servicehost application.
This means it runs as a service and does not need to be deployed to an IIS-instance.
There is an automatic WCF deploy tool in Visual Studio or copy the code to the server.
The server will be access like through a website like http://localhost:2342342432342/YourWebService.Svc.
You have to get the references from the WS using a tool that generates all the classes for you and you use that service's classes to write your code.
If your intention is to deploy to to a server that does not use IIS for hosting, you could look at an alternative hosting application like Cassini.

Hosting Web Service/WCF Service?

I'm new to Windows Azure and I'm trying to deploy my web application to Windows Azure.
In my app I used some web services, now I would like to know how can I build them in windows azure and include that web reference in my web app?
Some tutorials said that I have to import my current web service into a Cloud Service Project as a WebRole but in my web serivce folder, there's no csproj file.
Thanks!
I found out that I just have to create a new Window Azure Project and add a WCF Service Web Role, copy my old files in the old Web Service (maybe change a little bit if it's ASMX) then host it the same way as web application. And voila, everything is ok now :)
I think you should use a WebRole for a web service, but you can use a WorkerRole though.
Take a look on this:
http://www.devproconnections.com/article/windows-azure-platform3/Hosting-WCF-Services-on-Azure-101.aspx

Get Webservice WSDL in different project within same solution

I have a Web Service Project and a Web Site Project both within the same solution. I have a simple link on a web page within the Web Site Project that needs to point to a web services WSDL (example: Webservice.asmx?WSDL) within the Web Service Project. Is this possible?
Would I be better off using a hardcopy of the WSDL document and just putting that in my web site project?
I don't believe so. You will need to have the webservice run, in either IIS, or through visual studio.
Why not add a Web reference to the Webservice (Browse for "Web services in this solution") ?
That's what adding the reference does, basically... along with creation of the class mapping. Then you could always update references without having to worry about hard coded wsdl links.

Categories

Resources