WCF Web API Host Project Type - visual-studio

I am used to creating traditional WCF services and hosting them in IIS. I do this by creating a WCF Service Application within Visual Studio.
For my next project I want to leverage the functionality found in the new WCF Web API. However I am not sure what type of project I need to create to host the service.
Nearly all the examples I have read/seen show the service hosted in a ASP.NET Empty Web Application. Is this correct? Can I not host in in a WCF Application project and add the Web API references in that from NuGet?
I did try hosting in a WCF Application but soon fell over when it came to routing and the MapServiceRoute call in the Global.asax file which gets called on Application_Start.
Any help on this would be much appreciated.

For what I gathered from the samples, you can create the WCF as you have been creating, that is, a WCF Service Application in the WEB folder of Visual Studio.

Related

Using ASMX Web Reference in Windows Service

Is it possible to create a windows service where Web References are used?
I've written a windows service file which compiles up until I add my web references. The .vb code enclosed runs as a .aspx file in a different project, so the code is not erroneous. I, however, have been able to find no documentation claiming I cannot use a Web Reference in a windows service.
If I cannot use Web References in a windows service, how should I make a call to a .asmx from a windows service project?
Is not possible to use an ASMX web service inside a Window Service. You must use a WCF service.

Communication between wcf and windows service?

I have a situation where I want to establish communication between WCF service and Windows service.
I want to pass messages from the Windows service to the WCF service
I want to send array list from the Windows service to the WCF service
How can I achieve this?
Edit:WCF is hosted on IIS.
if any code snippets it would very helpfull.
Thanks in advance
loke
Yes you can, just add a reference to your wcf service in your windows service.
In Visual Studio right-click your project and choose Add Service Reference. Enter your WCF service address and choose namespace name. Visual Studio will download WSDL from you web service and create proxy for you.
Then just create proxy object and call web service methods:
YourNamespace.YourServiceClient client = new YourNamespace.YourServiceClient();
client.Open();
client.YourOperation();
client.Close();

Can I open SaveFileDialog (windows.form) in WCF Service class?

Need to generate document on the fly. for all the operation in application we are using WCF service.
(to generate the document we are plannign to use Syncfusion library, call is been made from ExtJs client and WCF service performs all db operation.)
Whats the possible solution for generating the document using WCF?
The WCF service is used to access the services from server in client mode, hence it’s not possible to open a Winforms application in WCF service. However you are trying the reverse action and we can’t access the remote application in server.
Please refer the below link for further clarifications.
How to create a file in WCF service application in windows
Thanks,
AL.Solai.

Need a step-by-step WCF as Windows Service

I'm trying to find a (good) step-by-step example of creating a WCF and hosting it as a Windows Service (with installer). I'm using VS2010 and have a simple WCF with 1 function (just returns 'Hello').
Please don't Google and post; I'm looking for a resource someone has actually used. Most of the Googling I've done hasn't turned up much for what I'm trying to do.
I just want to take my WCF library, and find a way to install it as a Window Service. I've done it in 2008, but 2010 is... Different.
For future reference - for anyone else looking at this thread:
Here is the best example I've found for what this question was looking for:
CodeProject: WCF Service with Windows Service Hosting, consumed from C# App!
This link mentioned above shows how to consume the WCF service, but with a lot of other stuff to wade through:
MSDN: How to: Host a WCF Service in a Managed Windows Service!
This second link above is good for creating the WCF service, but not for consuming it:
MSDN: Hosting and Consuming WCF Services!
I rarely find MSDN articles that I like :-)
You just need to host the wcf contract class in your onstart method of service calling ServiceHost host = new ServiceHost(YourClass) and in onclose method of your service you need call host.close(). The hosting option depends on what type of clients you want to talk to if you want to talk to pure html clients using REST you need to host your service in WebServiceHost and the binding you need to use in that case is webHttpBinding.
I have followed the following example and was able to create windows service hosted wcf and im sure this what you are looking for link
I did not find any difference in creating wcf service in vs2008 and vs2010.
What type of clients do you want to talk and which protocols do you want to support. This all defines your configuration.
What I've used when I use WCF in a Windows Service is Topshelf as a Windows service framework and a modified version of this Code Project code to dynamically host, install and run WCF services.
Topshelf makes it very easy to develop and debug because it can be run as a console application. Being able to dynamically update WCF service libraries without stopping the Windows service is just cool. ;)

how do I add a test web service to my project in Visual Studio?

I have a test web service replicating a live web service that hasn't been made public yet (It will be public when the app is released).
I added a new ASP.NET Web Service Application to my solution. Now when I try and add a web reference from the main project and choose "Browse To Web services in this solution" it doesn't find the test web service.
Am I missing an important step here?
Maybe the webservice you're trying to connect to isn't running . Do an F5, verify that the service has started by checking the address in the browser then try to add the refference again.
If it doesn't work, just specify the address by hand.

Resources