Java and .NET application communication - java

I don't think this is quite possible or if it is recommended to do... but is there a way to connect or comunicate or deploy Java and .NET application for method beside Web Services. I mean I understand there are Messaging server that allows Java application communicate to each other but I dont know if this can cross development environment, any suggestion about it or thoughts about this?
I'm limited to web and desktop environments.

Apache Thrift is a way to go. You will need to write a service definition like this:
serivce helloworld{
string sayHello(1:string name)
}
Thrift then will generate RPC interface with network layer already implemented, It support many others language such as Java, C#, PHP, Python. Thrift support binary protocol over TCP/IP, so it's very fast.
for more, go to its wiki page http://wiki.apache.org/thrift/

You can use something like Apache ActiveMQ which uses JMS on the Java side and the .NET Messaging API on the .NET side.

We ended up writing our own implementation of Java-.Net communication protocol based on Hessian (later added JSON as well), but Thrift is a valid option.

The virtual machines (JVM vs CLR) are not going to talk to each other except through some OS level open standard. Shared Files (yuck), Sockets and Web Services come to mind. There is nothing that would allow you to call a .net subroutine from java or vice-versa.

Related

Is WebORB suitable for Java -> .NET remoting and messaging

Does WebORB supports writing desktop clients in .NET (eg. WPF) and consuming remoting and messaging services in Java server using BlazeDS?
Alternatively, can BlazeDS in Java server be replaced by WebORB for Java without changing existing clients written in Flex?
Maybe you should start by asking this question on the WebORB forum.
I do think WebORB supports writing desktop clients in .NET as they have supported SilverLight in the past. I also think you can replace the BlazeDS by WebORB for jave as the AMF specification remains the same.
WebORB comes with a lot of examples, so your first questions should be quickly answered by looking at these examples.
I would suggest to use REST instead of AMF, but that's just me.
Does WebORB supports writing desktop clients in .NET (eg. WPF) and
consuming remoting and messaging services in Java server using
BlazeDS?
The .NET version of WebORB has an communication library for the desktop applications (http://www.themidnightcoders.com/fileadmin/docs/dotnet/v5/_net_client_overview.htm) and as you will see, the Remoting/RPC, Publish/Subscribe messaging, and RTMP data messaging are available with the library.
Some time ago, I did a simple example when the windows service communicates with the server and sends some data do it. The server updates data in its turn updates all connected FLEX clients. Although in example I used the WebORB server, I believe it could be replaced with any similar solution. The example in details and some code are available on my blog http://blog.scriptico.com/06/120/
Alternatively, can BlazeDS in Java server be replaced by WebORB for
Java without changing existing clients written in Flex?
I would say it could be replaced yet it depends how did developers write it. In the past, I had some experience with the migration from BlazeDs to WebORB. In the best case, you will not touch the FLEX client at all or just re-build it with the modified channel endpoint information.

Exposing C++ program as a Web Service

How to expose a C++ program as a Web Service?
Or is it a better idea to invoke C++ from Java and expose the resultant Java as a Web Service.
In any case, the C++ program should not undergo any changes.
Consume C++ program in Java WebService end point and expose java webservice
Use JNI to consume C++ program
Nice article from JavaWorld
Interestingly, webservices work on http protocol, which means that you can't "host" a webservice written in C++ without having an http server. Since each web server will have it's own mechanism of writing "hooks" or extensions, the next obvious question is which web server would you like to chose.
Let's say you want IIS on Windows. It's possible to use ISAPI extensions; so you need to know how to write one, which complies with web services standards. Or, alternatively, it's better to learn how to do it in C++ with Visual Studio, which will have lots of built-in stuff to help you get started.
In short, there is no "standard" way of exposing a web service in C++ and you have to be "platform" specific. Windows with IIS has one way of doing it. Apache Axis C++ has another.
You can try c-sevice-interface https://github.com/Taymindis/c-service-interface.
It create a C/C++ program as a service port and listening to NGINX fcgi.
This is a small bridge engine which can handle high load of request, any segfault will not break the engine, it will catch and free the thread, it is built on top NGINX, FCGI. You can setup the proxy, load balance, authentication via NGINX before reach to your interface.
The link shown as below is a wiki to Guide you how to startup from scratch.
https://github.com/Taymindis/backcurl/wiki/How-to-build-BackCurl-for-cpp-Android-development

Which Java technology should be used to build client-server applications on the server side?

I'm new in the Java world and I'm totally confused with the sheer number of Java server-side technologies. I need to build application with Java on the server side and Flex-AIR on the client. All communication between them must be on sockets and in AMF format.
Which technology would be suitable for this?
JPA+Spring. You can create service layer with Spring, and use it from you flex client.
I think tha given your constraints you should be looking at Blaze: http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/

How to connect .Net app to JMX agent?

I need to connect my .Net application to somebody else's JMX agent. I've read that this is simply not the done thing and I should use soap or practically anything else. As this is just not going to happen, are there any libraries or interop techniques out there that can help me? I'm only interested in the simple things like invoking a remote operation or returning a string result.
.NET is really not the technology to use to talk to JMX. JMX is a builtin standard that is part of Java but is pretty specific to running in Java. I would assume that you cannot control the application you are trying to consume since you indicate you are trying to use someone else's JMX agent.
In that case, you might want to consider writing your application or part of it in Java. That is the best way to get access to the JMX. If that is not an option you do have a few things you could look into:
1) Check to see if the application you are connecting to can expose the data as something other than JMX. It is usually not hard to allow access via web services to the same data.
2) Write a small Java wrapper that talks to the JMX server and exposes web services. This allows you to query the web services which in turn go over JMX.
3) There are other agents that JMX has to allow it to talk with different technologies. You could use something like the SNMP agent and use SNMP traps from .NET. More information on that can be found here: http://java.sun.com/javase/6/docs/technotes/guides/management/snmp.html
If you start up an HtmlAdaptorServer - you could just use the URLs to invoke JMX methods using standard HTTP calls.
I've done this in the past from Perl as part of a system administration task. Its not pretty and its unmaintainable if the JMX interfaces are changing a lot. But.. if you need a quick and dirty hack - this is it!
The Web Services Connector for Java Management Extensions (JMX) Agents and the reference implementation ws-jmx-connector would be my choice. JSR 262 will provide a new opportunity for cross-platform/cross-language enterprise integration projects, but development unfortunately has slowed down.
It would only require some SOAP calls to invoke all operations of the JMX management interface, IIRC even including callbacks/notifications.
You can do this with IKVM. It is a Java Byte Code to .Net CLR compiler and works just fine with JMX.

Techniques for Calling into a WCF Service from Java

Besides using Web Services, or POX (or custom HTTP), are there some other techniques that I could utilize for calling services exposed from WCF via ___________ to the Java world? These requests will be in the same machine. Maybe RAW TCP/IP?
I'm just inquiring for a project that we need to possible provide some method of calling synchronous code in the .NET world and return results to our Java world.
Thanks for suggestions.
To talk with a Java client you'll have to use one of the interoperable protocols which limits you to going across HTTP or HTTPS. TCP can only be used between clients running Windows on an intranet. Even on the same machine you won't be able to use Named Pipes either for the same reason.
The interoperable protocols are covered in Chapter 1 of "Programming WCF Services" by Juval Lowy.
You can try following project http://iiop-net.sourceforge.net/

Categories