我正在使用 Oracle 休息数据服务。所以我需要编写一个响应特定请求的程序。例如,
我在应用程序 Express ORDS 中收到请求,
request_body BLOB:= :body;
现在我需要为此请求创建响应。喜欢,
respond('application express ok'); // this sends to the client
谢谢你!
我正在使用 Oracle 休息数据服务。所以我需要编写一个响应特定请求的程序。例如,
我在应用程序 Express ORDS 中收到请求,
request_body BLOB:= :body;
现在我需要为此请求创建响应。喜欢,
respond('application express ok'); // this sends to the client
谢谢你!
您还应该提供文档类型和状态代码(以及您能想到的任何其他标题。
示例:JSON:
begin
owa_util.status_line (200, '', false);
owa_util.mime_header ('application/json', true);
htp.prn ('{"status":"everything is a ok"}');
end;
文本:
begin
owa_util.status_line (200, '', false);
owa_util.mime_header ('text/plain', true);
htp.prn ('everything is a ok');
end;
还有一个更大的例子使用标题:
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;
我找到了答案,这可以这样做,
begin
htp.p('your textual content as respond body');
end
使用上述语法可以创建响应正文。