views:

749

answers:

4

Overview: We are looking to write a C# user interface to select parts of our web applications. This is for a very captive audience (internally, for example).

Our web applications are written in PHP and/or Python using Apache as the web server.

Why? A well thought out native Windows interface can at times be far more effective than living with the rules imposed by a web browser.

Question: What is the best way to communicate between C# and PHP/Python using HTTPS? I'm speaking mostly of serialization / unserialization and conversion of the various data types resident in each language.

Ideally, we would have strongly typed structs or objects to work with in C#, and appropriate data structures created in PHP/Python to work with on that end. Code generators are fine.

I've looked at Apache Thrift, considered extending our internal data libraries, reviewed Google's Protocol Buffers, etc... Thrift looks promising, but their documentation is very sparse.

  1. Keeping developer overhead to a minimum is essential.
  2. Keeping performance reasonable , especially on the server side, is important.

Comments on the usefulness of XMLRPC, SOAP, or other related technologies would be welcome.

Any pointers?

A: 

Using web services sounds like the most appropriate way for your scenario.

Richard Hein
What? I get a vote down? If you have a C# Window front end, generating proxies from SOAP is a breeze.
Richard Hein
+3  A: 

I have no real experience with PHP, but I've done plenty of Python back-end web services consumed by front-end clients in a variety of languages and environment. SOAP is the only technology, out of those I've tried, that has mostly left a sour taste in my mouth -- too much "ceremony"/overhead. (Back in the far past I also tried Corba and, as soon as I was trying to interoperate among independed implementations for different languages, the feeling wasn't all that different;-).

XML-RPC, JSON, and protocol buffers, all proved quite usable for me.

Protocol buffers is what we normally use within Google, and I'm not sure what you find so under-documented about them -- please ask specific questions and I'll see what I can do to make our documentation better, officially or unofficially! Their main advantage is that they're so "tight" on the wire -- minimal overhead with maximum flexibility. JSON is great, too -- and not just for ease of use in Javascript clients, either: sometimes I've used it as the default format for communication among different languages, too, when no JS was involved at all!

Once you have your web app set up to emit (say) a protocol buffer, it's not hard at all to make it able to emit XML or JSON on request - one ?outputformat=JSON extra parameter in the GET request is all it takes, and picking the right output serializer is trivially easy (in Python, but, I'm sure, in PHP as well).

"Getting strongly typed objects" on your C# end is, in my view, a job you can best do in a C# layer on your end. No direct experience with that, but, for example, I have wrapped reception of protocol buffers in C++ into factory classes that spewed out perfectly formed and statically typed objects (or raised exceptions when the incoming data was not semantically correct); I know it wouldn't be any harder for JSON or XML, and I very much doubt it would be any harder for Java, C#, Python if you cared, or any other language that's any use at all in the real world!-)

Alex Martelli
Thank you for the very through perspective. By the way, I said "thrift" has sparse docs -- didn't comment on Protocol Buffers.
gahooa
A: 

I have done this using a PHP SOAP Server and VB.Net client. Once you connect the VB.Net/C# client to the server (the location of the WSDL file) C# will automatically detect all the functions and all the objects that are exposed. Making programming much easier.

I would also recommend using NuSOAP which I found to be more functional. http://sourceforge.net/projects/nusoap/

Webber
A: 

I recommend the PHP/Java Bridge. Don't let the name fool you. This can be used to connect both PHP and Python to any ECMA-335 virtual machine (Java and C#)!

http://php-java-bridge.sourceforge.net/pjb/

To answer your comment:

The communication works in both directions, the JSR 223 interface can be used to connect to a running PHP server (Apache/IIS, FastCGI, ...) so that Java components can call PHP instances and PHP scripts can invoke CLR (e.g. VB.NET, C#, COM) or Java (e.g. Java, KAWA, JRuby) based applications or transfer control back to the environment where the request came from. The bridge can be set up to automatically start a PHP front-end or start a Java/.NET back end, if needed.

slypete
Thanks for the pointer. My intended usage was to connect a C# client application to a PHP/or/Python back-end system. Does that apply, or is it backward from the usage of the php-java-bridge?
gahooa