Starting WCF Client in IIS - c#

It is possible to have WCF Client that connects persistantly using duplex over net.tcp (netTcpBinding) from IIS?
i.e. the normal way would be to host it in a console app or as a windows service, my question is, could one use a shared hosting type of environment to run a WCF Client application.
i.e. the application isn't ever accessible from the outside, the application just connects to another service and consumes a remote WCF service over the internet.

If the ASP.NET app is the client, you could try loading the WCF Client into an Application or Session variable.
I've done something slightly similar with a System Timer and it worked a treat.

Related

Communication between service and app - RESTful?

I am generating an app that would communicate with a service and show the service status in the taskbar. To do this communication, I am thinking of using RESTful WCF services. However, my question is, since REST would have to expose a port, is there a more efficient/secure way to do this? I am assuming the app and service will be on the same machine or possibly within the same LAN/ Active Directory domain.

Call a WCF Service from client side

I am going to create a WCF service(IIS host) and it will be called from client side javascript code.
When I call a WCF from client side, is the WCF a WCF library or WCF application type?
For example:
I have the javascript below.
function AddFunds() {
var postObject = {
myID: myObject.myIDNumber,
LocationID: myObject.LocationID,
fundsToAdd: CurrencyFormatted($("#txtAddFunds").val())
};
$.post('/OrServices/myService.svc/AddFunds',
JSON.stringify(postObject)
).success(AddFundsResult);
}
In the beginning, I have to create WCF Service "myService.svc", but I am not sure if it is a library or application or doesn't matter.
this answer describes the difference:
A service application includes a website host already setup for you. A service library is a library of services that a host can reference and startup.
If you start with a service library (recommended) you can then choose
any host you wish (a windows service, IIS/ASP.NET, or even a console
application) and you'd just reference your library from your new host.
Choosing a Service Application limits your host to just IIS/ASP.NET
(though this might be ok for your purposes, but will limit the
protocols you can use).
Edit: Changes in IIS since I wrote this allow for a wider variety of
protocols on ASP.NET activated services, so choosing a service
application is much less limiting than before.
if your only going to host in IIS then I would recommend to just use a Service Application. As a lot of the work is done for you.

Two way communication using netTCPBinding

I am new to WCF (Just a day or 2). I am planning to make an application having Client/Server
WCF Service (On Server hosted as windows service):
Will invoke some commands using (Process.Start())
Will send some information from my database
Questions:
What WCF binding should I use? WsDualhttp or netTCP (Please elaborate if you can)
Does WCF works with SqlServer + EF 4.1
Server UI:
This will primarily will be used to
Start ot stop the above service
Change Address (localhost to [My Ip address]) and Port
Show status of service (Running or dead)
Questions:
How can I Change the address and port of my WCF service from this UI (it will be a different project and hence different config file).
Client App:
Used to issue commands to WCF service.
Get to know if the service is running or dead.
Receive status messages for task completion or faults.
Also, can the windows installer be combined to install ServerUI + WCF Service + Windows service?
WCF Service
Here are a couple links on choosing the right binding. Based on the scenario you're describing, I'd go with the netTCP.
C# - WCF - inter-process communication
Choosing the right WCF binding
WCF and SQL Server are independent of each other, so I wouldn't expect any problems using the Windows service to interact with your database.
I'd suggest reading up on how to start a process from a Windows service.
Server UI
I would suggest hosting another WCF service in your Windows service for interacting with your Server UI. You can use the netNamedPipeBinding since this communication channel will always be local, i.e., on the same box. So your Windows service will host two WCF services - one for the external communication with the client and one for the local communication with the configuration UI.
Installer
Yes, the Windows installer can be used, but that might be overkill for what you're describing. Of the Server UI, WCF Service, and Windows service, the only one that absolutely requires installation is the Windows service. The others could theoretically run simply by copying the assemblies to the target system. You might consider having the Windows service install itself via command line. That way you could get away with a self-extracting executable using software like WinZip. This might be less heavyweight than a formal install. If you go this route, have a look at the step-by-step here.
Ha a look at WCF duplex services:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
Why do you want to have a interface to an windows service? And if you have access to IIS7 and WAS, I would recommend to use it instead of self-hosting in windows service.
Here is a good starting point for WCF Configuration Management:
http://msdn.microsoft.com/en-us/library/ff650534.aspx
Yes, you can use windows installer.
Cheers
--Jocke

WCF TCP Binding setup between IIS and Service

I developed a WCF service, and now reading about the bindings. It s said that TCP binding is the fastest one, which i like to use, but it requires WCF to WCF communication? What s that exactly means?
I have a an application that s on IIS 7, using ASP.NET and a WCF service. they are on different machines. can i use TCP binding?
When i try tcp binding from client (IIS 7) to WCF service, i m getting connection error.
is it possible to connect to WCF service using only tcp binding from another server with IIS 7?
if there is , how to do it? I open the port on firewall etc. oh , wcftestclient works, my app doesnt. :(
again, CLIENT IS ASP.NET PAGE, SERVICE IS WCF, in the SAME NETWORK.
IIS uses http. So if your intent is to communicate from a WCF client to an ASP.NET application you should use the http binding. In IIS7, you have to manually go through a series of steps to enable non-HTTP bindings, but it's possible. This MSDN article show you how you can do this
http://msdn.microsoft.com/en-us/magazine/cc163357.aspx
If your client application is the ASP.NET application then yes, you should be able to use TCP binding between you ASP.NET application (that is acting as a WCF client) and your other application that is NOT an ASP.NET application but a regular application that is a WCF service
What you might want to try is build a console application as your WCF client using TCP binding and then:
Run it from the same box as your service and ensure things are working correctly.
Run it from the IIS box against your WCF service running on the other box and see if it works.
If both these work then it should work from your ASP.NET application as well.

IIS Proxy for a Windows Service hosted WCF Service

I have a Windows Service that is exposing a WCF service thru a net.tcp channel.
Now I want this service to be exposed thru IIS, without being hosted in it. By doing that I will be able to maintain the state in the Windows Service, and I will benefit of the underlying IIS authentication and security.
Is it possible to do that just by using some configurations? Maybe a kind of proxy or passthrough?
UPDATE
Why am I doing that? A good question:
Some processes are running at a scheduled interval, asynchronously.
IIS is recycling AppPools and to trigger it, usually a web request should be issued, so that the AppPool is started.
I can't expose directly the service as a Web service in the Windows Service, because IIS is installed and binded to the IP Address that I want to use.
If I want to expose the service for many clients, using their own TLD, I don't want to have the same process running on each website (maybe for exclusive locks, or just for memory/CPU usage)
Perhaps this clarifies a little the need...
No you have to implement whole new layer in IIS. You will expose new WCF service which will call your WCF service hosted in Windows service. Is it really needed? Why don't you host the service in IIS directly or why don't you expose HTTP endpoint on your Windows service? What state do you maintain in Windows service?

Categories

Resources