Calling C++ RPC services with the GWT - c++

what is the best way to implement C++ functionality in Java?
Currently I call a RPC service which, throw JNI calls the C++ function and returns the result to the client. Since this methode produces a big overhead, I wanted to know if somebody had a simimlar problem and how he solved it?
Regards,
Stefan

Use JNA or JNI

I suppose you are using GWT on client side. You can use JSON to call C++ services..

Related

Convert gRPC channel from C++ to Java

I have a library, that already uses a C++ version of gRPC, and I need to implement a Java wrapper.
Thus, I need to use Java Native Interface (JNI) to convert std::shared_ptr<grpc::Channel> to gRPC-Java Channel.
More specifically, I need to implement the following Java function:
public native ManagedChannel CreateChannel(String address);
that references this existing C++ function:
std::shared_ptr<grpc::Channel> CreateChannel(std::string address);
Is it possible to do this?
Possible? Yes. Easy? No.
The Channel/ManagedChannel API mainly has the newCall() method. Implementing that method would be annoying as you'd need to map MethodDescriptor and CallOptions to the C++ equivalents. But the bigger problem is it returns a ClientCall which would take more work to implement.
C++ uses a different API for flow control than Java, so you'd have to map those. The C++ callback API would be ideal in this situation, but it not currently available (time of writing: 2019 Q4). So that would mean creating threads and using the async API.
Very probably not. The Java implementation was not specifically designed to be interoperable with the C++ implementation, so it has its own pure Java ManagedChannel implementation.

How do I call .NET from c++ in as a platform-independent way as possible

I have a C++ app from which I want to call .NET (C#) methods. I was going to use C++/CLI, but it is only supported on Windows.
Since also we support the MAC, I'd like to call .NET from C++ in a way that will work on both Windows and Mac (with Mono).
What is the best way to do this?
EDIT: I should add that the c# code we wish to call is not ours. We have no way of making any changes to it. The c++ code, of course, is ours.
The easiest way is to expose the functionality via a function pointer. Both .Net and native code can interop with C/C++ code in the form of a function pointer. Function pointers are supported on all platforms where C++ code runs hence it can be written without any understanding of .Net.

Scala equivalent to wsdl2java?

Is ther any equivalent to wsdl2java that will take a WSDL file and generate scala stubs for the server and/or client?
I googled, but either there isn't or my google-fu is weak.
scalaxb has some support for this, but it's still very much experimental and it's still client-side only. The only reliable techniques I've seen for handling the server side is either to generate the Java code via
wsdl2java or other tools and then wrap that in Scala or, possibly, to use annotations to generate the WSDL from the Scala code. The later option is likely to lead to some pain, though, as you learn where Scala does and does not map readily to Java conventions.
Not sure if it is what you want, but have you looked at http://scalaxb.org/wsdl-support?
Looking at this old thread it seems possible to create custom mapping templates:
http://www.mail-archive.com/axis-user#ws.apache.org/msg35857.html
Maybe you could use wsdl2java tool with custom templates creating Scala code?
Thinking one can try to combine wsdl2avro and avro4s

Is there a popular C++ service framework?

... like Remoting or WCF in C# or Java RMI?
I am learning c++ and need a simple to use tcp service framework with built in binary serialization for c++ to c++ communication.
Thanks
Apache Thrift or Google's Protocol Buffers are probably the two that will suit your needs the best.
I think you will have to drop the 'simple' part. Try Corba (portable) or DCOM (almost only Windows).
You could use boost MPI but it's quite complex, however library for use in distributed-memory parallel application programming.
You could use more simpler solution for c++, implementing your own dispatchers using ie. protocol-buffers from google or even json. Then parsing it using some design patterns like 'command' to execute some methods.

What is the best way to access SOAP WebServices from portable native code?

I need to access a SOAP webservice (written in .NET with MS SQL backend, FWIW) from several different platforms, so my common denominator is native C++. Is there a portable library for this or I should roll my own solution?
To do SOAP in C++ you need both a networking and an XML/SOAP library. These aren't easy to find, especially if cross-platform is needed.
I would start from libcurl. There seems to be a SOAP example available.
It's possible that using Java rather than C++ might actually be easier. Java does run in lots of places and has quite nice Web Service client libraries.
Is that worth a look?