简体   繁体   English

DataSnap Server抱怨服务器方法不存在……Delphi 2010 DataSnap

[英]DataSnap Server complaining about Server Method not existing …Delphi 2010 DataSnap

I have a DataSnap Server with a Server method like this: 我有一个具有以下Server方法的DataSnap Server:

function TServerMethods1.selectFalzUser(Usuario: string) : TDataSet;

Now, on the DataSnap Client using TSQLServerMethod, I successfully connect to the server in Design Mode, pull server's methods list ... select 'selectFalzUser'... and I can succesfully see my params, both Usuario as INput, and the output TDataset Param... when a try to set my SqlServerMethod Active ... I get the following error: 现在,在使用TSQLServerMethod的DataSnap Client上,我成功地在设计模式下连接到服务器,提取服务器的方法列表...选择'selectFalzUser'...,然后我可以成功地看到我的参数,既是Usuario作为INput,又是输出TDataset参数...尝试将我的SqlServerMethod设置为Active时...出现以下错误:

Error Remote error: TServerMethods1.selectFalzUserwhereUsuario method not found in the server method list. 错误远程错误:在服务器方法列表中找不到TServerMethods1.selectFalzUserwhereUsuario方法。

Why Delphi is appending 'whereUsuario' string to the method name? 为什么Delphi将'whereUsuario'字符串附加到方法名称上? Obviously TServerMethods1.selectFalzUserwhereUsuario does not exist. 显然,TServerMethods1.selectFalzUserwhereUsuario不存在。

Regards 问候

zaguerino. 扎格里诺。

Without seeing more code it is hard to say why it isn't reporting the method name correctly. 没有看到更多代码,很难说为什么它没有正确报告方法名称。 However, it doesn't sound like you are using DataSnap quite right. 但是,听起来您使用DataSnap并不正确。 Here is what I have done successfully for several projects: 这是我为多个项目成功完成的工作:

You must include {$METHODINFO ON} before the TServerMethods class definition and {$METHODINFO OFF} after the class definition in the DataSnap server. 在DataSnap服务器中,必须在TServerMethods类定义之前包括{$METHODINFO ON} ,在类定义之后包括{$METHODINFO OFF} Then compile and run your DS server. 然后编译并运行您的DS服务器。

On the client side, add a TSQLConnection component and set its properties to connect to your listing DS server. 在客户端,添加一个TSQLConnection组件并设置其属性以连接到列表DS服务器。 Then right click the TSQLConnection and select Generate DataSnap client classes . 然后右键单击TSQLConnection然后选择“ Generate DataSnap client classes Save this as something like ProxyMethods.pas and include it in your client project. 将其另存为ProxyMethods.pas类的ProxyMethods.pas并将其包含在客户端项目中。 Then you can access the ProxyMethods class to call any of the published TServerMethods in the server. 然后,您可以访问ProxyMethods类以调用服务器中任何已发布的TServerMethods

Also, returning TDataSet won't work with the approach I described because TDataSet is not a marshallable datatype, however OleVariant is. 另外,返回TDataSet不适用于我描述的方法,因为TDataSet不是可编组的数据类型,但是OleVariant是。 I have had good success with returning a TClientDataSet.Data , and then on the client side I can assign this directly the Data property of a client-side TClientDataSet . 我已经成功地返回了TClientDataSet.Data ,然后在客户端可以直接将其分配给客户端TClientDataSetData属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM