0

Me and my friends are developing a project, and here are the inputs so far:

  1. There is a CRM-like website, written with JSm with its own DB, authentificaion and everything, hosted on *nix system.
  2. There is a Control Cash Machine pluged into user's computer
  3. There is a .Net application, which is a wrapper for cash machine driver.

Here is what we would like to implement:

  1. User installs .Net application on a machine with a cash machine plugged into, and registers it on a website;
  2. Whenever user click a button on a website, the assosiated with user .Net application runs method with arguments (based on data from a website), interacting with cash machine (register a buy, print a check, etc.);
  3. User can be logged into a website from a different machine, not the one with a cash machine plugged, and still be able to send commands to .Net application;
  4. Communication between server and .Net application has to be secure.

My question is "Using what technologies should we implement such functionality and what are the steps?"

So far I've been looking into ActiveX, creating HttpListener, using SignalR, using custom URL protocol and everything has mixed up in my head, so I'm a bit confused.

I would appreciate any advices or opinions on the situation. Thank you

UPDATE:

Clarifications:

The site and its communication with DB is written in JavaScript, RubyOnRails and Python and is hosted on *nix system.

Polling server by application for commands seems inapropriate to me, since user expects fast reaction to his actions. Obviously there must be some connection between application and server, the question is what kind of connection and how to implement it

1 Answer 1

2

I'd suggest looking into WCF. Make sure to configure the WCF server to use SSL (possibly 2-way) and it should be reasonably secure. I'll assume you know, or can find out, how to create secure PKI credentials/certificates.

You can have your web server respond to certain requests by opening a connection to the WCF server (probably HTTP) and issuing a SOAP (or plain old XML) request, which the WCF server interprets and uses to interact with the cash machine.

So then:
  User web browser —> web server + SOAP client —> .NET driver application + WCF server —> Cash Machine

First, decide what your "service contract" will be (that is, what you want your web service to be able to do), and create an interface for it:

namespace MyCashMachine
{
        [ServiceContract(Namespace = "http://example.com/CashMachine")] //Note that this is the xmlns-namespace used in the WSDL/schema, not your endpoint.
        public interface ICashMachineService
        {
            [OperationContract]
            void GimmehMoniez(int howMuch);
            [OperationContract]
            boolean UHazMoniez();
            [OperationContract]
            int GetMoniezLeft();
        }
}

Then implement your service!

namespace MyCashMachine
{
    /* Make the machine spit money! */
    public class CashMachineService : ICashMachineService
    {
        public boolean GimmehMoniez(int howMuch)
        {
            try {
                CashMachine.eject(howMuch); //I don't know what methods your driver exposes...
                return true;
            } catch (CashMachineException cme) {
                return false;
            }
        }
    }
/* and so on */
}

Then configure WCF to run on the machine connected to the cash machine. For this, see one of the hundreds of tutorials, or read the MSDN documentation.

There are libraries in Ruby and Python to help you deal with the SOAP web interface without having to do things like build a SOAP request from scratch.

You can also configure WCF to work with plain old XML. I'd recommend working through some of the tutorials to explore how it works. It's a pretty steep learning curve, but once you have the tool in your tool chest, you'll find it indispensable while doing anything with web services in .NET.

A wonderful resource with sample implementations is this post on REST/SOAP endpoints for WCF.

3
  • Hi, Eric. Thank you for your answer. I've been looking into WCF and there are some things that stay unclear to me. Can WCF be used on a website, that doesn't use ASP and is hosted on *nix server? Will the website be able to invoke service on a different machine, not the one its displayed on? Could you please put in some details on implementation? Thank you
    – netaholic
    Mar 20, 2015 at 13:52
  • To give you more information, I'll need some idea what your endpoint looks like and what kinds of messages it's expecting. WCF "normally" wants SOAP-style messages, although you can configure it to work with plain XML. I'd recommend implementing a SOAP endpoint on your server. Mar 20, 2015 at 14:07
  • @netaholic You won't be able to host WCF server on non-windows environment. But you should be able to consume messages from WCF. It would be helpful if you could specify what technology do you use in CRM (PHP, Java, nodejs, other?), since this might affect recommendations you will get. Mar 20, 2015 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.