使用utl_http调用rest服务时,我收到错误响应以下的消息。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>
URL:https:// 主机名 /svc/snservice-consolidation/v2.0/api/sn/GetSNDetails?Out=CAE&Mode=XML
伪代码:
UTL_HTTP.set_wallet (
'file:/var/opt/oracle/wallets/........',
'xxxxxxx');
l_url :='https://<hostname>/svc/snservice-consolidation/v2.0/api/sn/GetSNDetails?Out=CAE'
|| CHR (38)
|| 'Mode=XML';
l_http_request := UTL_HTTP.begin_request (l_url, 'POST', 'HTTPS/1.1');
UTL_HTTP.set_authentication (l_http_request,'UN','PWD');
p_req_clob := TO_CLOB ('<root>
<Device SerialNumber="AAAAAAAAAA"/>
</root>'
);
UTL_HTTP.set_header (l_http_request, 'Content-Type', 'text/xml');
UTL_HTTP.set_header (l_http_request,
'Content-Length',
LENGTH (p_req_clob));
UTL_HTTP.write_text (l_http_request, p_req_clob);
l_http_response := UTL_HTTP.get_response (l_http_request);
附加说明:
感谢对此事的任何帮助。预先感谢。
关于, 查尔斯
答案 0 :(得分:0)
也许是报价问题,请尝试以下操作:
res XMLTYPE;
BEGIN
SELECT
XMLELEMENT("root",
XMLELEMENT("Device", XMLATTRIBUTES('AAAAAAAAAA' AS "SerialNumber")))
INTO res
FROM dual;
p_req_clob := res.GetClobVal();
答案 1 :(得分:0)
尝试一下:
l_http_request := UTL_HTTP.begin_request (l_url, 'POST', 'HTTP/1.1');