Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to create a windows service for reading some machines data for the customer client application. But, I dont have option host the service in IIS. Customer can only consume the service through web url using webrequest. Is there any possibility to consume the WCF service hosted in windows service using webrequest.

Hosting method should not be in IIS and consuming the service should be a type of webrequest (I dont have any idea on this). client will only call net.tcp,http URL types to consume the service.

Thanks in advance.


What I have tried:

I searched in many websites but i'm helpless
Posted
Updated 8-Apr-19 6:21am
Comments
[no name] 8-Apr-19 12:06pm    
Why do you think you to "host the service in IIS" for a client to make / "consume" a web request? One has nothing to do with the other.

1 solution

Yes it's possible, all you have to do is make your code act as a basic web server. Listen on a port (it doesn't have to be port 80, if IIS is running on the machine it will probably have to be something other than 80 though) and when a request comes in it will be an http request message.

HTTP/1.1: Request[^]

The easiest way to understand what HTTP requests look like is to use the debug tools in your browser and look at the network tab as you request pages, the format is quite simple. Once your service has received a message, parse the request and do whatever work is required to fulfil the request and return an appropriately formatted response. Again you can work out what the response should look like by looking at responses in the debug tools of your browser.

If you google for something like "c# make basic web server" you'll probably find a lot of the code is out there already.
 
Share this answer
 
Comments
raddevus 8-Apr-19 13:59pm    
Fantastic! I was just reading this and I googled for a solution and the answer at https://stackoverflow.com/questions/3159213/how-do-i-create-a-simple-web-server-using-wcf-without-the-servicehost-class is really great. You can run that example in LINQPad.net (https://www.linqpad.net) with the following using statements:
System.Runtime.Serialization, System.ServiceModel.Channels, System.ServiceModel, System.ServiceModel.Web
Member 11265837 9-Apr-19 0:27am    
@F-ES Sitecore, Great. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900