如果我在这个框架中有自定义值对象,我该怎么办?我已经声明并定义了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对象。
有任何想法吗?
非常感谢
答案 0 :(得分:0)
很抱歉迟到的回复。
您的问题是只有root代理对象会忽略其完整包。而所有其他类和接口都使用其全名进行搜索。这意味着Objective-C世界中的LoginRequest
类将存在于Java世界的默认包中。它很可能不会。
解决方案是添加翻译:
[CWHessianArchiver setClassName:@"com.mycompany.LoginRequest"
forClass:[LoginRequest class]];
我为v2.0添加了更好的支持,其中可以为两端定义默认包/前缀。例如,Java中的com.mycompany.
和Obj-C中的MC
。不幸的是,v2.0分支对于生产还不够稳定。