首页 文章

如何更改REST DataSnap中的Content-Type响应

提问于
浏览
3

我有一个由 WebBroker REST 制作的项目,作为服务运行,我需要将 Cotent-Type 响应更改为 application/json ,默认情况下 WebBroker REST 带来了我的结果

Content-Type'text / html;字符集= ISO-8859-1'

我通过访问方法更改响应

GetInvocationMetadata(True).ResponseContentType ='application / json'

Data.DBXPlatform 类,但它仍然没有解决它,它在当前的一个下方添加了另一个 Content-Type .

这只发生在 WebBroker REST ,如果我通过DataSnap Server创建项目,我通常会得到它 . 但是我需要 WebBroker REST 才能访问客户端发送给我的信息 .

如何解决问题的示例 .

  • DataSnap REST Application 创建项目

在ServerMethods类中,执行相同的模型 .

uses System.StrUtils, Data.DBXPlatform;

function TServerMethods1.EchoString(Value: string): string;
begin
  Result := Value;
  GetInvocationMetadata.ResponseContentType := 'application/json';
end;

示例响应标头 .

连接:关闭
内容类型:text / html;字符集= ISO-8859-1
内容长度:25
日期:2013年9月10日星期二16:41:37 GMT
Pragma:dssession = 542354.126073.592372,dssessionexpires = 1200000
Content-Type:application / json

1 回答

相关问题