For the latest project, record it.
First, let the J2EE brothers pass the interface classes implemented by the server Hessian and the public methods of this interface class into and return the classes that need to be serialized to themselves, and copy will also work, you can also compress it into a jar package.
The package name and Class Name of the interface-related classes must also be the same as that of the server.
The rest is that the client has added the hessdroid package, a third-party Hessian library for Android.
The call is simple. The following is the sample code:
Hessianproxyfactory factory = new hessianproxyfactory (); // If user authentication is required // factory. setuser ("uname"); // factory. setpassword ("XXX"); factory. setreadtimeout (5000); // This is the same interface used by the server, from the J2EE brothers, or the jar packages they provide are also the same, as long as the package name class name is the same. Xxxxinterfaceservice ifs = factory. create (xxxxinterfaceservice. class, URL, getclass (). getclassloader (); // these two methods are used to set whether the Hessian Protocol version is 2nd or not. If not, enter false // factory. sethessian2reply (false); // factory. sethessian2request (false); // now you can directly call the method in the interface, just as locally response r = ifs. getsomthing ("somthing ");
It is much easier than WebService.
By the way, remote rpc.
This year, we have to be brave enough. As long as it is an android client, we have to say it is cloud, isn't it?
Which one is not interacting with the server? As for how to interact, I used to prefer JSON, which is much better than soap such as WebService. As a cloud developer, do you dare to let the poor GPRS traffic of the user transmit XML which is larger than the actual data?
First, it is very troublesome to implement WebService on Android, and ksoap2 is really troublesome to use. Second, who can find the WebService package in JDK's default javax under the SDK? Google has already threw it away and replaced it with JSON.
Hessian is indeed a good choice. hessdroid is well configured on the client, and several lines of code are done. The transmitted binary data is also serialized. Capture the HTTP packet by yourself, the advantages and disadvantages of various remote rpc technologies can be minimized.