How to host a WCF service - c#

I am trying to create a chat application in WCF.
I've created the client and the service on a localhost using httpBinding,
this is the service endpoint:
http://localhost:9999/ProductService
Now, I really don't know how to make the program run 'globaly' and not on a localhost.
Is there anyway to host the server on my pc? or run the application serverless using p2p communications?
Thanks anyway for your Time

You can set up at publicly accessible web server on your own computer, but it's definitely not recommended for any production purposes, unless you have a good understanding of this and have a internet-connection that allows for it, both technically and legally.
You should probably get external web hosting for this instead.
But if you really want to do this, you can install IIS to host the service.
As a side note, I don't think WCF is the optimal route to take for this anymore. Maybee you should check out SignalR and/or WebSockets instead. And ASP.NET Core WebAPI. It's not really anything wrong with WCF, but for new projects I wouldn't recommend it.

Related

Possible problems with Owin SignalR hosted in IIS 10 Express or IIS 10?

this is my first questions on SO. Normaly I just wander the internet reading stuff until I can make up a solution.
So up until now we use HTTP Request and Response Model to communicate with Clients.
Using C# ASP.Net .Net Framework 4.0 hosted in IIS.
This way we are not able to forward information in real time to them from the server.
We would need to wait till the clients contact the server.
To solve this issue I think OWIN with SignalR V2 Middleware hosted in IIS would give us the ability to use Remote Procedure Calls, so whenever something happens that needs to be forwarded immediately to the Client, we can do so by calling that specific clients function or all clients.
For this of course the target Framework of the application needs to be .Net Framework 4.5 at least.
Now the problem I have is that in the Microsoft Documentation it says to use the IIS Express version, in order to enable the server to have more than 10 connections.
On the client side it would be no problem as ideally there would only be one connection at any given time.
But the Server should be able to have a whole lot more than just 10. As the Websocketconnections would stay open.
I am not an IIS expert, but why are there these limitations in the non Express version?
I would expect that one should be able to set the number of maximum connections despite the IIS version?
What are the gains of using IIS instead of self-hosting OWIN?
I would guess that I would need to implement some security features myself?
On my development PC a client Windows Service with SignalR V2 is able to communicate with an OWIN SignalR V2 hosted in IIS application.
At the moment I need to evaluate what needs to be considered to set this up on a server to ensure functionality.
I hope this all makes sense.
I am implementing Remote Procedure Calls in our Webservice, for real time communication with clients.
I read documentations about RPC, SignalR V2, OWIN and Katana.
At the moment I need to evaluate what needs to be considered to set this up on a server to ensure functionality.

Communicating Azure Web app with WCF Web App

I need to host ASP.NET based app as Azure Web App which should communicate with WCF based Azure Web App. ( WCF app is also an azure Web App not an on-premise app at all).
What are possible ways to achieve easy and flexible communication between both app services?
Do we need to establish a communication channel specifically?
Both Apps under IIS On-Premises are used to communicate without any problem over NET TCP protocol. But I think now we need both services to communicate over HTTP instead of Net TCP?
What problems we may have?
What things do we need to bear in mind?
First of all, we need to be clear that azure webapp only supports ports 80 and 443.
Secondly, in your project, you said that it runs normally in local, because I don't know what you mean by communicate, and I don't know how to achieve it. Normal communication may be socket or websocket, etc. It is not clear what communication you are talking about. If it is socket and you need to use a port other than 443/80, then it is not supported.
But I know clearly that azure web app supports wcf, which means that both of your webapps can be deployed successfully and run normally. If there is a problem, you can update the error details in the post, and we can provide you with further assistance.

C# Client-Server application

I need to write a client-server application. First of all, I'm going to write an application server. Also my app server should connect to database(MS Sql Server) and give data from it to client app. So, as I know, I should use WCF. Is it a good idea? Maybe I need to take a look for something else?
Lets start with client-server architecture.
Assuming you have finalized that you need client and server, but have you decided carefully the architecture? I mean what type of server and what type of client you are going to create?
Let's see the options here:
Server
1. What type of hosting you are going to use?
2. What type and how much load your server needs to handle?
Client
1. Type of consumer of your service
2. Do client need to be deployed on local machine or it should be web based?
There are obviously more concerns than above. Initial design should be as flexible as possible.
So, now lets look at some solutions regarding architecture.
Server:
1. Application Hosted WCF server: Each time you need to manage the server lifecycle. Also, this is not scalable. So if you are looking for scalable architecture, you need to look more.
2. IIS hosted WCF server: This might be a good idea along with some architecture concerns as per your need.
3. Web Method: Obviously this came after WCF, but WCF is still in its place. So the main difference is at What is the difference between an asp.net web method and a wcf service?
Now Client:
1. ASP.NET: This will enable to use a single client app for every platform obviously because of HTML
2. WPF/WinForms: This is going to bit tricky to use as client as you need to deploy the client app on user machine and here comes the data security problem. In former you can directly use SSL or some other way to send data to browser. While in this if you are not using WCF with HTTPS and there are some proprietary data going over wires, it may be concerns.
If you are looking for cross platform usage of your server you can use HTML.
Conclusion:
You can use Server as WCF hosted service (either in IIS or in self contained application) and client as ASP.NET.
-----------------------------If it is not big enough requirement then you can use ASP.NET as server and then browser as client (No need to create client).----------------------------
You can create server either as WCF as web methods and deploy the client on user machine.
----------------------------
WCF is nice enough and it can handle your proprietary data types as well.
WCF is a nice thing, but i would use ASP.Net Self-Hosted Web-API. It's more modern. And you have a full rest interface, which is much more popular.
Here is a comparison: WCF and ASP.NET Web API
Here is a good starting point: Self-Host ASP.NET Web API 1 (C#)

WCF self hosting and IIS

Does WCF self hosting, still uses IIS or some Virtual Server based on IIS.
Eg: After coding a very basic WCF host, it s possible to invoke an endpoint such as
http://localhost:9090/foo.svc
For example: invoking a WCF host via TCP, does that use IIS internally?
I m trying to avoid IIS due to another app i m using, which doenst work with IIS Threads. That s why asking. so i d like to manage my own AppDomain and threadpool rather than IIS.
Any recommendation?
Can i seperate hosting of WCF from IIS?
When you self-host, you are using not a shred of IIS at all. You don't need IIS on that machine - nothing.
WCF self-hosting will require the http.sys driver for its http-based communication - but that's all there is. There is absolutely no trace of IIS needed - none, zip, nada.
Self-hosting WCF also allows you to pick your own service addresses and use whatever suits your needs - there's no virtual directory and no *.svc file to be dealt with.
It depends on the bindings. if you do a BasicHttpBinding, then all the communication will be over HTTP.
As for hosting WCF, there is the test server that comes with Visual Studio that you can use (it runs as a service. It's called WcfSvcHost.exe), but I wouldn't recommend it for production. If you are just testing, then you could just launch the WCF in the Visual Studio debugger and use its address all you want (it will be http://localhost:1234/foo.svc in that case)
If you are looking for a production hosting, you can use WCF as a SOAP endpoint, and here there is a pretty good article over at The Code Project that talks about creating a service for self hosting

how to create a c# app to listen for xmls and reply in xml

I know that you can create web services in .net and have them run on iis. I'd like to make something that doesn't rely on iis as the webserver I'm using runs apache.
The eventual app should listen for incoming xml documents and repy in the form of an xml document, the client application will be running Javascript and sending xmls via http post requests. Is this something that SOAP handles?
All the guides and tutorials seem to follow the microsoft way, all hosted on servers running iis... is there a way around this?
As you can tell I'm quite confused as how to start.
I would strongly advise against implementing your own web service hosting platform - this really isn't a trivial thing to implement, especially if you want to be passing proper web service messages between your servers.
One option that would allow you to utilize WCF and Microsoft's baked in web service functionality is hosting WCF as a standalone service. In this model, you aren't using IIS to host the web service - you trade off some monitoring and logging functionality baked into IIS but it doesn't require IIS be installed.
Here's an article on WCF hosting options - http://msdn.microsoft.com/en-us/library/bb332338.aspx

Categories