我已经用 Delphi 编写了一个 DataSnap 服务器,现在正在用 Objective-C 编写一个 iPhone 客户端应用程序来使用它的数据。我首先简单地调用一个简单的方法来返回一个字符串 - 请参阅代码:
NSString *sReverseStr;
DSRESTConnection *connDSREST;
TServerMethods *dsClient;
connDSREST = [[DSRESTConnection alloc] initWithDelegate:self];
[connDSREST setHost:@"192.168.0.19"];
[connDSREST setPort:80];
[connDSREST setProtocol:@"http"];
[connDSREST setUserName:@"user"];
[connDSREST setPassword:@"pass"];
dsClient = [[TServerMethods alloc] initWithConnection:connDSREST];
sReverseStr = [dsClient ReverseString:@"Goodbye"];
“ReverseString”方法应该返回文本“eybdooG”,但它只是返回空白,并且我在 DataSnap 服务器上没有看到任何连接活动side - 就好像该方法根本没有被调用。有趣的是,如果我没有设置 DSRESTConnection 的 UserName 和 Password 属性,那么它会尝试连接到服务器并且我可以看到该活动,但连接失败并显示“401:未经授权”,因为我的 DataSnap 服务器需要用户凭据。
是否有人使用 Objective-C 成功连接到 DataSnap 服务器(无论是否有用户凭据)?
如果我错过了一些明显的事情,我深表歉意,因为我只使用 Xcode 2 天,所以仍然没有找到自己的立足点。
I've written a DataSnap server in Delphi, and am now writing an iPhone client app in Objective-C to consume it's data. I'm starting simple by just calling a simple method to return a string - see code :
NSString *sReverseStr;
DSRESTConnection *connDSREST;
TServerMethods *dsClient;
connDSREST = [[DSRESTConnection alloc] initWithDelegate:self];
[connDSREST setHost:@"192.168.0.19"];
[connDSREST setPort:80];
[connDSREST setProtocol:@"http"];
[connDSREST setUserName:@"user"];
[connDSREST setPassword:@"pass"];
dsClient = [[TServerMethods alloc] initWithConnection:connDSREST];
sReverseStr = [dsClient ReverseString:@"Goodbye"];
The 'ReverseString' method should return the text 'eybdooG' but it just returns blank, and I don't see any connection activity on the DataSnap server side - it's as if the method isn't being called at all. Interestingly, if I don't set the UserName and Password properties of the DSRESTConnection then it does try to connect to the server and I can see the activity, but the connection fails with '401: Unauthorised' because my DataSnap server requires user credentials.
Has anybody successfully connected to a DataSnap server with Objective-C, either with or without user credentials?
Apologies if I've missed something obvious, only been using Xcode for 2 days so still finding my feet.
发布评论
评论(1)
只是为了更新这一点 - Embarcadero 已确认这是 iOS DataSnap 框架中的一个错误并已修复它。该错误位于 DSRESTConnection.m 中,其 sourceforge 存储库中有一个新的修复版本:
http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/Delphi/DataSnap/connectors/
乔纳森
Just to update this - Embarcadero have confirmed this as a bug in the iOS DataSnap framework and have fixed it. The bug was in DSRESTConnection.m and there is a new fixed version in their sourceforge repository here :
http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/Delphi/DataSnap/connectors/
Jonathan