oracle - 在 Oracle PLSQL 中使用 UTL_HTTP 调用 Rest Webservice 时出错
问题描述
使用 utl_http 调用休息服务时,我得到以下错误响应。
<!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);
补充说明:
- 相同的 Web 服务在 Postman 等其他客户端中运行良好
- 相同的后端代码适用于另一个接受相同数据输入的类似服务。
感谢您对此事的任何帮助。提前致谢。
问候,查尔斯
解决方案
试试这个:
l_http_request := UTL_HTTP.begin_request (l_url, 'POST', 'HTTP/1.1');
推荐阅读
- ios - 尝试在 swift iOS 中本地保存 4 mb mp4 文件时崩溃
- java - 将带有表连接结果列表的 nativeQuery 获取到 JSONObject
- javascript - 如何屏蔽 ApolloServer 中的错误并返回不同的响应
- android - 我无法在 sql server 的子类中发布我的值
- git - 如何合并非源存储库中的特定文件?
- angular - 无法在 mat-icon 中加载自定义 SVG
- php - 通过直接 URL 的全局变量或无法访问的链接
- pm2 - PM2 无法在集群模式下写入日志文件
- php - 重置 mPDF 中的 writeHTML() 缓冲区
- r - R data.table 按列值设置子集