Search code examples
iphoneobjective-cobjecthessian

Custom objects with HessianKit and java backend


I have an iPhone app that uses HessianKit to talk to my java server. A couple of the methods I use return custom objects, and I haven't been able to figure out how to make them load as the correct object on the iPhone side.

Here is basically what I have:

in java:

public class QRSet implements Serializable{
{

  protected Pagination pagination;//another custom class
  protected int resultSetSize;
  protected List results;

  //...standard getters, setters, and constructors...
}

In objective-c

@protocol QRSet <NSObject>

@property (strong, atomic) id<Pagination> pagination;
@property int resultSetSize;
@property (strong, atomic) NSArray * results;

//...not sure how I would need to do getters and setters here...


@end

Originally I had the objective c version as its own class instead of a protocol, but I found there had been a change in how the mapping method works and now it requires this format:

[CWHessianArchiver setClassName:@"com.test.queries.QRSet" forProtocol:@protocol(QRSet)];

This is how I call my service:

 id<QRSet> qrSet = [self.proxy doPaginatedList:token :filter :startingIndex];

This however is where I am stuck, if I make my method call to return the QRSet, I still only get an NSDictionary object. Does anyone know what steps I am missing to get it to recreate the QRSet object on the client side?


Solution

  • For objects that are returned from the service, you need to specify the mapping in the CWHessianUnarchiver, like this:

    [CWHessianUnarchiver setProtocol:@protocol(QRSet) forClassName:@"com.test.queries.QRSet"];