DataSnap与JSON序列化(4)

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]}

http://localhost:8080/datasnap/rest/TServerMethods1/ReverseString/AB%20CDE%E4%B8%8A%E6%B5%B7FG%E3%80%81%5C%2F%3F%5C

 

但是如果用外网的IP来调用时,就出现错误:

http://210.x.x.x:8080/datasnap/rest/TServerMethods1/ReverseString/AB%20CDE%E4%B8%8A%E6%B5%B7FG%E3%80%81%5C%2F%3F%5C

错误信息是: 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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

火星牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值