delphi prism作为datasnap client可以调用delphi写的REST Server中的方法。
首先,可能是测试版的缘故,某些datasnap的组件,如TAdoDbxDatasnapConnection,在工具箱中没有安装,需要手动安装,C:/Program Files/Common Files/CodeGear Shared/Delphi Prism/Shared Assemblies/7.0/Borland.Data.AdoDBXClient.dll
datasnap调用写法:
http get的写法是:
注意参数的编码,需要使用函数system.Uri.EscapeDataString()来编码。
比如,参数:AB CDE上海FG、//?/,会被转义为:AB%20CDE%E4%B8%8A%E6%B5%B7FG%E3%80%81%5C%2F%3F%5C
出现一个问题,
当用localhost这样调用时,没有问题,得到:{"result":[//?/u3001GF/u6D77/u4E0AEDC BA]}
但是如果用外网的IP来调用时,就出现错误:
错误信息是: 500 Internal Server Error,The request was rejected by the HTTP filter. Contact the server administrator. (12217)
而参数换成简单的ABCD就可以:
http://210.x.x.x:8080/datasnap/rest/TServerMethods1/ReverseString/ABCD