Hessian - Objective-C 2.0 Implementation
From Resin 3.0
Contents |
Introduction to 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.
The three main goals of HessianKit are:
- To be as compliant and forgiving as possible.
- Provide seamless Objective-C experience against web services implemented in Java.
- Avoid glue-code.
The example code is written to be compatible with, and mirror the example code from Hessian Java API Overview.
The Service API
Assume the following Hessian service's API is provided as a plain old Java interface.
Hello, World API - Java
public interface BasicAPI { public String hello(); }
Client Implementation
The client must declare the same interface in Objective-C.
Hello, World API - Objective-C
@protocol BasicAPI -(NSString*)hello; @end
Then creating a client is as simple as creating an API interface:
Hello, World Client - Objective-C
NSURL* url = [NSURL URLWithString@"http://www.caucho.com/hessian/test/basic"]; id<BasicAPI> proxy = (id<BasicApi>)[CWHessianConnection proxyWithURL:url protocol:@protocol(basicAPI)]; NSLog(@"hello: %@", [proxy hello]);