views:

177

answers:

9

Can you give me some advice on how to best ensure that two applications (one in C#, the other in Java) will be compatible and efficient in exchanging data? Are there any gotchas that you have encountered?

The scenario is point to point, one host is a service provider and the other is a service consumer.

+1  A: 

You can use something like XML (which isn't always that efficient) or you need to come up with your own proprietary binary format (efficient but a lot more work). I'd start with XML and if bandwidth becomes a problem, you can always switch to a proprietary binary format.

Something like SOAP (Wikipedia) is supported by both C# and Java.

TLiebe
+3  A: 

Have a look at protobuf data interchange format. A .NET implementation is also available.

kgiannakakis
Does this support C#?
Matthew Murdoch
Yes, see my edited answer.
kgiannakakis
Looking at the documentation, it only supports C++, Java and Python at the moment, but protocol buffers are a good and efficient way to exchange data (much more efficient than for example XML).
Jesper
Ah, thanks for the protobuf-net addition.
Jesper
A: 

Make sure that you use a well defined protocol in order to communicate the data, and write tests in order to ensure that the applications responds according to contract.

Alexander Kjäll
+3  A: 

JSON for descriptive data, and XML for general data types. If that is not efficient enough for you, you need to roll your own codecs to handle the byte ordering difference between C# and Java.

CLR is supposed to be platform independent: http://en.wikipedia.org/wiki/Common_Language_Infrastructure
A: 

This is such a broad question but I'd recommend focusing on standards that apply to both platforms; XML or some other standard form of serialization, using REST for services if they need to interoperate.

David in Dakota
+1  A: 

We use C#/VB.Net for our Web interfaces and Java for our thick client. We use XML and webservices to communicate between the database and application servers. It works very well.

northpole
+2  A: 

Rather than focus on a particular technology, the best advice I can give is spend time focusing on the interface between the two (whether that be a web service, a database, or something else entirely). If it is a web service, for example, focus on creating a clear WDSL document. Interface, interface, interface. For the most part, try to ignore the specific technologies on each end, outside of some prototyping to ensure both languages support your choices.

Also, outside of major roadblocks, don't focus on efficiency. Focus on clarity. You'll likely have two teams (i.e. different people) working on either end of this interface. Making sure they use it correctly is far more important than making things just a little faster.

Ken Wootton
+1  A: 

If you have Java as a webserver, you can use Jax-WS ( https://jax-ws.dev.java.net/ ) to create webservices and WCF for .Net to connect to the Java Webserver..

Wael Awada
A: 

If you use XML, you can actually externalize your data access as XPath statements which can be stored in a shared resource used by both applications. That's a start.

Jherico