使用 HessianKit 和 java 后端的自定义对象
我有一个 iPhone 应用程序,它使用 HessianKit 与我的 java 服务器通信。我使用的一些方法返回自定义对象,但我无法弄清楚如何使它们作为 iPhone 端的正确对象加载。
这基本上是我所拥有的:
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
最初我将 Objective C 版本作为自己的类而不是协议,但我发现映射方法的工作方式发生了变化,现在它需要这种格式:
[CWHessianArchiver setClassName:@"com.test.queries.QRSet" forProtocol:@protocol(QRSet)];
这就是我调用服务的方式:
id<QRSet> qrSet = [self.proxy doPaginatedList:token :filter :startingIndex];
然而,这就是我陷入困境的地方,如果我调用方法来返回 QRSet,我仍然只能得到一个 NSDictionary 对象。有谁知道我缺少哪些步骤来让它在客户端重新创建 QRSet 对象?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于从服务返回的对象,您需要在 CWHessianUnarchiver 中指定映射,如下所示:
For objects that are returned from the service, you need to specify the mapping in the CWHessianUnarchiver, like this: