c# rest webservice without IIS - c#

Is there a good example/tutorial on how to create and run WCF REST webservice without IIS ?
I want to have a console application that'll run the webservice and not host it in IIS.

Just self host your service with System.ServiceModel.Web.WebServiceHost in your console application. It will wire up the appropriate endpoint behavior / binding.

Related

WCF singleton hosted in windows service. How to auto start WCF without first "touching" the service with client

I have a WCF service hosted in windows service.
Currently when the windows service starts i have to "touch" the WCF service with a client to run some long running code in WCF service.
Is it somehow possible to auto start the long running code in WCF service without calling the service with a client?
IIS 7.5 is not an option.
Yes, use OnStart method for this. It will be triggered once the Windows service gets a START command from OS.
Put your "touch" code (logic) there.

Hosting a WCF webservice and WCF Net.Tcp service in the same IIS container?

I'm trying to build a system which consists of:
A centralized IIS component
A Client application written in .Net
A Third party application.
The .Net Client should on startup connect to a WCF Net.Tcp Binding on the IIS application and register it's self as a consumer of requests (Callbacks).
The Third party application will then make Web Service calls to the IIS server which will farm out the request to the .Net Clients.
How do I host mutliple WCF services IIS? Is this possible?
I assume that I'd have to instantiate the services in the web.config as endpoints but I'm not sure how to do this.
You could use multiple SVC files hosted within the same application or you could use MVC-style Routing to establish the multiple ServiceHosts.
Here is an MSDN example on hosting WCF within IIS using web.config and SVC files.

How to assess a Windows Service hosted WCF service from another WCF service hosted in IIS7?

I have done a work which contains two parts
WCF service which is hosted in Windows Service
WCF service project hosted in IIS7
I have done both comfortably,But i got a problem?
I want to call a method from WCF service hosted in WS from the 2nd WCF service hosted in IIS, but i was unable to do that? Can anybody help in this?
You should be able to configure a client endpoint in the service being hosted in IIS to the service being hosted as a Windows service, and make your call through a proxy just as you would normally make a call to a WCF service.
Well, if your service hosted in IIS7 wants to call the other service, it needs to become a client of that other service.
So basically, in Visual Studio or on the command line, you need to create a service reference to your second service, so that you'll get a client-side proxy class, which you can then use to call the second service. Also, you will need to add some configuration settings to your web.config for the service hosted in IIS7 in order for it to be able to call the other service (in a Windows service).
So where exactly are you stuck??

Silverlight Accessing WCF and CrossDomainAccessPolicy without IIS

I have a Windows Service that exposes a WCF service and so I'm not using IIS. I'm suddenly getting the famous SecurityException that mentions using a cross-domain policy when I try to access the service from a Silverlight app. However, since I'm not using IIS, does that mean I need to have a web server on the same port as my WCF service just to serve this file? Is there a better way to do it?
You can add another service with webHttpBinding (REST) that serves out ClientAccessPolicy.xml file. Then in your Windows Service, you can start that endpoint along with the other one so that Silverlight clients can get the cross-domain policy file. You can find more information in below links:
Step By Step - Using Silverlight to Access a WCF Service Hosted In a Console Application
Self hosted WCF service and enabling cross domain calls

calling a WCF service object method in another WCF service

I using two WCF services. WCF service A is hosted in my .NET Winform application and WCF Service B is hosted on a Windows Service.
I am able to instantiate a client for WCF Service B and use the methods - i.e. call the WCF service hosted on Windows service from the .NET Winform app.
I am not able to accomplish the reverse with WCF Service A - i.e. call the WCF Service hosted on the .NET Winform application from the Windows Service. The call to the method times out.
I have used the WCF Test client from the Visual Studio command prompt and it can successfully make calls to WCF Service A.
Is this due to a security issue or something from the Windows Service?
Please advise.
Thanks in advance!
Subbu
I think the only viable approach (without the extreme of having some messaging infrastructure), is to have the service invoke operations back on your client via a WCF callback. A good example of this can be found here:
What steps do I need to take to use WCF Callbacks?
This is good for dealing with events that happen server side and allowing the client to respond to them. If events isn't what you're looking for, then your client could just register with the server (specifying the callback contract), and then the server can invoke your client at will.

Categories