下载地址: http://sourceforge.net/projects/hessiankit/
介绍:http://www.jayway.com/2008/07/10/hessiankit-released/
协议介绍 http://hessian.caucho.com/
HessianKit
HessianKit is a Framework for Objective-C 2.0 to allow Mac OS X 10.5, and iPhone 2.0 applications to seamlessly communicate with hessian web services.
HessianKit provided typed proxy objects to formward calls to, and and handle responses from any hessian web service, seamlessly just as if they where local objects. HessianKit also provide functionality to automatically generate classes for published value objects. Both web service proxies and value objects are defined as basic Objective-C Protocols.
Unless the client uses custom value objects, CWHessianConnection
is the only class in HessianKit that is needed to be created directly. Instances of CWDistantHessianObject
are fetched from CWHessianConnection
using proxyWithURL:protocol:
. If custom value objects are needed use the CWValueObject
to realize objects using protocol definitions, or implement classes conforming to CWNSCoding
protocol.
If the web service exposes the following Java-interface:
public interface Service { int getPersonCount(); Person getPerson(int index); }
Then the Objective-C client would define the service Protocol as this:
@protocol Service -(int)getPersonCount; -(id<Person>)getPerson:(int)index; @end
Assumin Person
is a value object defined as this in Java:
public class Persson implements Serializable { private int age; private String name; public Person(int age, String name) { setAge(age); setName(name); } public int getAge() { return age; } public void setAge(int v) { age = v; } public String getName() { return name; } public void setName(String v) { name = v; } }
The Objective-C client would define the same value object as a Protocol like this:
@protocol Person @property(assign, nonatomic) int age; @property(retain, nonatomic) NSString* name; @end
Value object from the web service will automatically be created as a subclas of CWValueObject
if the class name matches a defined protocol. Value object to be sent to the web service can be created useing the class method valueObjectWithProtocol:
of CWValueObject
, or by using any class conforming to NSCoding
.
Given the above example the code to get all available persons and write their age and name to logs, could be wimplemented as this:
NSURL* url = [URL URLWithString:@"http:/someserver.org/hessianservice"]; id<Service> proxy = [CWHessianConnection rootProxyWithURL:url protocol:@protocol(Service)]; int count = [proxy getPersonCount]; for (int index = 0; index < count; index++) { id<Person> person = [proxy getPerson:index]; NSLog(@"age: %d name: %@", person.age, person.name); }
Since Java and Objective-C differ in the naming of methods, some translation must be done when sending call tho the hessian web service. Method names are first looked up using the class method methodNameForSelector:
of CWHessianArchiver
, if a method name is not returned, the method name to use will be generated with these steps:
- Split the selector name on ':' delimiter character.
- Capitalize first charcter of all splitted parts but the first.
- Join splitted parts without delimiter.
- If method takes one or more arguments the nme is mangled by appending "__#" where # is the number of arguments.
Some examples of method tranlsations:
Objective-C Java doFoo
doFoo
getFoo:
getFoo__1
doFoo:bar:
doFooBar__2
doUgly:::
doUgly__3
Many Objective-C constructs feels alien in Java and vice versa, therefor non-automatic method translation can somethimes be prefered, in the above interface
Service
the method namedperson
is not good looking Objective-C, albeit acceptable Java. To add a manual translation just do:[CWHessianArchiver setMethodName:@"getPersonCount" forSelector:@selector(personcount)]; [CWHessianArchiver setMethodName:@"getPerson" forSelector:@selector(personAtIndex:)];
And change the Objective-C Protocol accordingly:
@protocol Service -(int)personCount; -(id<Person>)personAtIndex:(int)index; @end
And now the much more Objective-C friendly code can be written:
NSURL* url = [URL URLWithString:@"http:/someserver.org/hessianservice"]; id<Service> proxy = [CWHessianConnection proxyWithURL:url protocol:@protocol(Service)]; int count = [proxy personCount]; for (int index = 0; index < count; index++) { id<Person> person = [proxy personAtIndex:index]; NSLog(@"age: %d name: %@", person.age, person.name);
相关推荐
提供hessian-4.0.37.jar下载,及服务器端与客户端通信的实例
基于Springmvc+hibernate+Hessian开发需要的架包
hessian jar包,包括源码jar
Hessian与Spring整合需要jar包,需要的同学进行下载学习
Hessian android客户端异步请求访问包
hessian关于java使用的一个小例子
Hessian多个版本下载,包括Hessian3.1.6,Hessian3.2.1,Hessian4.0.7
hessian接口包,性能测试实例
java hessian-3.0.38.jar。修改了原生的jar包,解决了hessian 序列化BigDecimal的精度问题。注意,请在hessian服务端和客户端中分别替换此jar包哦!! 只替换服务端hessian jar包还是会有问题。
Hessian(C#)介绍及使用说明Hessian(C#)介绍及使用说明
远程方法调用的比较,Hessian方法的介绍和相关配置.Hessian是一个轻量级的remoting on http工具,...只是它不使用SOAP协议,但相比webservice而言更简单、快捷。这个文件可以是hessian在spring项目和web项目的简单配置
收集的jar包,实际使用无问题,欢迎下载,如不能使用,请及时联系发布者 简介:hessian的4.0.33.jar
一个简单的Hessian,简单介绍了Hessian的使用方式,介绍了Hessian和Spring集成的使用方式,以及单独使用Hessian的方式。
hessian与spring整合的jar包
Hessian 是一种轻量级的二进制RPC通讯框架,基于HTTP使用servlet 暴漏web service. 本文描述了单独使用和及spring集成使用,并介绍了证书加密,签名及非证书类如DES加密方式. 文尾附官方实例链接.
hessian 使用实例,更简单的service
android端使用hessian跟web服务器通讯,导入即可运行,有问题请在博客留言。http://blog.csdn.net/tan313/article/details/49536891
赠送jar包:hessian-4.0.63.jar; 赠送原API文档:hessian-4.0.63-javadoc.jar; 赠送源代码:hessian-4.0.63-sources.jar; 赠送Maven依赖信息文件:hessian-4.0.63.pom; 包含翻译后的API文档:hessian-4.0.63-...
赠送jar包:hessian-3.3.6.jar; 赠送原API文档:hessian-3.3.6-javadoc.jar; 赠送源代码:hessian-3.3.6-sources.jar; 赠送Maven依赖信息文件:hessian-3.3.6.pom; 包含翻译后的API文档:hessian-3.3.6-javadoc-...
srpingMVC+hessian4整合jar包,工程里拷出来的,绝对可用