The by far easiest way to consume a web service on an iPhone is to use Hessian. Implement the server in Java using the official Hessian distribution, or in .NET using HessianC#.
Let us assume you have defined the following interface for your web service, and implemented it as a HessianServlet
(Just replace a HttpServlet
):
public interface MyService {
public String doWithStuff(String action, Object stuff);
}
It is just as easy on .NET.
On the client side use HessianKit, where you create proxies to the web service, and then use them just as if they where local object. First you must conbert the Java interface above to an Objective-C protocol.
@protocol MySertvice
-(NSString)do:(NSString*)action withStuff:(id)stuff;
@end
Then use it as a proxy, just as if it was a local object:
id<MyService> proxy = [CWHessianConnection proxyWithURL:serviceURL
protocol:@protocol(MyService)];
NSLog(@"%@", [proxy do:@"Something" withStuff:arguments]);
Hessian in a binary web service protocol, meaning allot smaller payloads, which is good on a slow GSM connection. Hessian is also much easier to encode and decode, compared to XML and JSON, meaning your app can make calls and receive responses using less CPU, and memory for temporary objects.