I have created a C# project thats consists from a backend service running under LocalSystem account and a GUI running under current logged-in user account.
These two parts communicate through named pipe, implemented as:
SERVICE:
PipeHost = new ServiceHost(this, new Uri[] { new Uri("net.pipe://localhost") });
PipeHost.AddServiceEndpoint(typeof(IPipeComm), new NetNamedPipeBinding(), "MyProgComm");
PipeHost.Open();
GUI:
ChannelFactory<IPipeComm> PipeFactory = new ChannelFactory<IPipeComm>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/MyProgComm"));
IPipeComm PipeProxy = PipeFactory.CreateChannel();
All working sweet, but now i'm stuck at a new feature they asked me to add. I must find a way to communicate with service (at least one-way towards service) from a mobile device, let's say Android, connected to the same LAN.
At first i thought about building a simple Android native app that would communicate with a TCP server added in service.
This requires some serious research from me, since i never did something like that before.
So allow me to ask: Which is the easiest way to accomplish this?
Can i utilise the existed named pipe for such purpose to save time and coding?
Can this be done by adding a minimal web server, in order to avoid creating a mobile device app and just use its browser? (i'd really preffer that!)
I'm confused, so a couple of guidelines would be really appreciated...
One of the questions you are asking is whether your NetNamedPipeBinding
will work in this scenario. It will not. WCF uses NetNamedPipeBinding
for when the service is on the same machine as a process communicating with the service. That is not the case in the scenario you describe.
What you are asking about is fairly large topic, but here's one pointer to start with: try switching to using a BasicHttpBinding
or a WSHttpBinding
instead, since these can handle the scenario where the client is not on the same machine as the service. To get familiarity with this, you could perhaps focus on getting them running from code on a PC contacting your server first. Note, there are real security implications for whether you choose Basic vs WS bindings. You'll have to figure out what your security needs are and how to proceed. If this is an intranet, you may be able to get away with fairly simple security, but the fact that you are talking about a mobile device makes this sound more complicated.
Your next step will be to figure out how to get this working on a mobile device. If your mobile device is not a windows device, some of the ease of use of WCF will be lost. (On a windows device could probably still use a svcutil generated client to call your service). Here's where I think you may want to consider using a RESTful web service via WCF. Getting your Android app to talk to a Restful service is probably bit simpler than getting it talk to the service via a wsdl, but both will work.