使用 HessianKit 和 java 后端的自定义对象

发布于 2025-01-03 16:42:21 字数 1089 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎樣才叫好 2025-01-10 16:42:21

对于从服务返回的对象,您需要在 CWHessianUnarchiver 中指定映射,如下所示:

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

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"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文