user173683
user173683

Reputation:

How to use webservice in iphone objective c?

I need great video tutorial for using webservices in iphone objective c.My requirment is already values are in webservice, so just i want to access the webservice and validate username and password and return back to true or false get value display on the iphone.

If anybody have idea about tutorial please help me out..

Upvotes: 3

Views: 30551

Answers (2)

Felixyz
Felixyz

Reputation: 19143

iPhone on Rails is

an Objective-C port of Ruby on Rails' ActiveResource.

but it can be used as a wrapper to access any RESTful webservice. ObjC classes and objects correspond to ActiveRecord classes and objects (which correspond to data base tables and rows).

There's an introductory screencast over here.

Upvotes: 1

PeyloW
PeyloW

Reputation: 36752

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.

Upvotes: 4

Related Questions