如何在Oracle REST数据服务中编程响应

如何在Oracle REST数据服务中编程响应,oracle,plsql,oracle-apex,oracle-ords,Oracle,Plsql,Oracle Apex,Oracle Ords,我正在使用Oracle rest数据服务。所以我需要为一个特定的请求编写一个响应程序。比如, 我在应用程序Express中收到一个请求 request_body BLOB:= :body; 现在我需要为这个请求创建一个响应。像 respond('application express ok'); // this sends to the client 谢谢大家! 我找到了答案,可以这样做 begin htp.p('your textual content as respond body');

我正在使用Oracle rest数据服务。所以我需要为一个特定的请求编写一个响应程序。比如,

我在应用程序Express中收到一个请求

request_body BLOB:= :body;
现在我需要为这个请求创建一个响应。像

respond('application express ok'); // this sends to the client

谢谢大家!

我找到了答案,可以这样做

begin
htp.p('your textual content as respond body');
end

使用上述语法可以创建响应体。

我找到了答案,可以这样做

begin
htp.p('your textual content as respond body');
end

使用上述语法可以创建响应正文。

您还应该提供文档类型和状态代码(以及您可以想到的任何其他标题)

例如: JSON:

正文:

还有一个更大的使用标题的示例:

declare
   l_response   varchar2 (32767);
begin
   l_response := '<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Response</title>
</head>
<body>
<h2>Thank you for submitting</h2>
</body>
</html>';
   owa_util.status_line (200, '', false);
   htp.p ('Content-Type: text/html; charset="iso-8859-1"');
   htp.p ('Content-length: ' || trim (to_char (length (l_response), '999999999999999999')));
   owa_util.http_header_close;
   htp.prn (l_response);
end;
声明
l_响应varchar2(32767);
开始
l_响应:='
回应
谢谢你提交
';
owa_util.status_行(200',false);
htp.p('Content-Type:text/html;charset=“iso-8859-1”);
htp.p('Content-length:'| | trim(to_char(长度(l_响应),'9999999999'));
owa_util.http_头\u关闭;
htp.prn(l_响应);
结束;

您还应该提供文档类型和状态代码(以及您可以想到的任何其他标题)

例如: JSON:

正文:

还有一个更大的使用标题的示例:

declare
   l_response   varchar2 (32767);
begin
   l_response := '<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Response</title>
</head>
<body>
<h2>Thank you for submitting</h2>
</body>
</html>';
   owa_util.status_line (200, '', false);
   htp.p ('Content-Type: text/html; charset="iso-8859-1"');
   htp.p ('Content-length: ' || trim (to_char (length (l_response), '999999999999999999')));
   owa_util.http_header_close;
   htp.prn (l_response);
end;
声明
l_响应varchar2(32767);
开始
l_响应:='
回应
谢谢你提交
';
owa_util.status_行(200',false);
htp.p('Content-Type:text/html;charset=“iso-8859-1”);
htp.p('Content-length:'| | trim(to_char(长度(l_响应),'9999999999'));
owa_util.http_头\u关闭;
htp.prn(l_响应);
结束;