views:

85

answers:

2

How do you connect C# back-end with a C++ front-end via HTTP or web-service equivalent?

A: 

The C++ accesses the exposed parts of the back-end via HTTP-Requests in which form you choose (webservice and others).

Femaref
Do you have an example, or more complete example? I could not find one.
buttercup
Do you have example of back-end C#, or at least how it should be.
buttercup
A: 

There are three parts here; the server (sounds like C#), the client (sounds like C++) and the transport. Taking them separately, and starting with the most important:

  • the transport: big decision here is what shape you want the data to be in. You mention protocol buffers, so we're talking binary - but that could be:

    • a raw octet-stream (think: downloading an image from a web-server)
    • a SOAP web-service returning a stream or byte[]
    • the same SOAP web-service returning MTOM

    Any should work; which to choose depends on the tools available. The important thing is : get a chunk of binary over the wire.

    You also need to think about the data definition at this point; a .proto file can define your schema, and most protocol buffers implementations include a tool to generate matching classes.

  • the server: depending on the choice above, this is either going to be a handler (IHttpHandler) or a web-service class. Either way, their job is really to run some logic and return a byte stream. How you get your data is up to you, then ultimately the job is to populate the DTO types (generated from .proto in many cases, but not strictly necessary) and run it through the serialization API, writing the result to the stream
  • the client: same in reverse; generate your DTOs from the .proto, and run it through the deserialization API

The various protobuf implementations (C++, C#, etc) are listed here.

Marc Gravell
I saw all of them. Do you accept paypal to write an open-source example which demonstrates using C++ and C# together in web-service?
buttercup
@buttercup - I'm genuinely not good enough at C++ to help with that. I can show you getting protobuf data on the wire from C#, *sure*. Then it should just be a case of deconstructing that from C++. There is (IIRC) plenty of C++ documentation, or maybe posting to the specific group might help: http://groups.google.com/group/protobuf
Marc Gravell
@buttercup - based on your "pay-ware" point about avoiding SOAP, I'd also suggest that raw octet-stream is the way to go in this case.
Marc Gravell
next related question: how do you start HTTP transport from MFC/C++ ?
buttercup
And to repeat; I can't advise on that. I'm not a C++ expert, sorry.
Marc Gravell
I'll split, can you write the server-side example, and someone else writes the C++ client example?
buttercup
Answer for C# side is here:http://marcgravell.blogspot.com/2010/06/extending-aspnet-mvc-with-custom.html
buttercup