0

如果我在这个框架中有自定义值对象,我该怎么办?我已经声明并定义了 LoginRequest 和 LoginResponse 的接口和实现,并且声明了 LoginRequest 和 LoginResponse 的协议。我在我的代码中找不到错误。代码如下:

//mycode
    NSURL* url = [NSURL URLWithString:myurl];
    id<BusinessAPI> proxy = (id<BusinessAPI>)[CWHessianConnection rootProxyWithServiceURL:url protocol:@protocol(BusinessAPI)];

    LoginRequest* loginRequest = [[LoginRequest alloc] init];

    loginRequest.mobileNum = @"123456789";//number.text;
    loginRequest.mobileType = @"iphone";
    loginRequest.password = @"123";//password.text;

    LoginResponse *loginResponse = [proxy loginBusiness:loginRequest];
    if (loginResponse.login) NSLog(@"YES");
    else NSLog(@"NO");

日志是“参数类型不匹配”
结果是 Web 服务器找不到远程 LoginRequest 对象。有任何想法吗?多谢

4

1 回答 1

0

这么晚才回复很抱歉。

您的问题是只有根代理对象会忽略其完整包。而所有其他类和接口都使用它们的全名进行搜索。这意味着您LoginRequest在 Objective-C 世界中的类将被期望存在于 Java 世界中的默认包中。它很可能不会。

解决方案是添加这样的翻译:

[CWHessianArchiver setClassName:@"com.mycompany.LoginRequest"
                       forClass:[LoginRequest class]];

我为 v2.0 添加了对此的更好支持,其中可以为两端定义默认包/前缀。例如com.mycompany.在 Java 和MCObj-C 中。不幸的是,v2.0 分支对于生产来说还不够稳定。

于 2011-01-02T19:33:19.873 回答