从Oracle pl/sql调用Soap Webservice-获取错误

5n0oy7gb  于 2023-06-22  发布在  Oracle
关注(0)|答案(1)|浏览(151)

当我调用SOAP服务时,我得到“ORA-29266:已到达主体末端”错误。我使用公共测试API”(如http://www.dataaccess.com/webservicesserver/NumberConversion.wso")来测试我的脚本
我的剧本是这样的:

DECLARE
  req          UTL_HTTP.req;
  resp         UTL_HTTP.resp;
  url          VARCHAR2(200) := 'http://www.dataaccess.com/webservicesserver/NumberConversion.wso';
  action       VARCHAR2(200) := 'http://www.dataaccess.com/webservicesserver/NumberConversion.wso/NumberToWords';
  envelope     XMLTYPE := XMLTYPE('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.dataaccess.com/webservicesserver/">
                                  <soapenv:Header/>
                                  <soapenv:Body>
                                    <web:NumberToWords>
                                      <web:ubiNum>4</web:ubiNum>
                                    </web:NumberToWords>
                                  </soapenv:Body>
                                </soapenv:Envelope>');
  buffer       VARCHAR2(32767);
BEGIN
  req := UTL_HTTP.begin_request(url, 'POST', 'HTTP/1.1');
  UTL_HTTP.set_header(req, 'Content-Type', 'text/xml');
  UTL_HTTP.set_header(req, 'SOAPAction', action);
  UTL_HTTP.set_header(req, 'Content-Length', LENGTH(envelope.getClobVal()));
  UTL_HTTP.write_text(req, envelope.getClobVal());
  resp := UTL_HTTP.get_response(req);
  LOOP
    UTL_HTTP.read_line(resp, buffer);
     DBMS_OUTPUT.put_line(buffer);
    EXIT WHEN resp.status_code = 200; 
  END LOOP;
  UTL_HTTP.end_response(resp);  
END;

通常我应该得到这个响应并从中提取数据:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <m:NumberToWordsResponse xmlns:m="http://www.dataaccess.com/webservicesserver/">
         <m:NumberToWordsResult>forty seven thousand eight hundred and ninety nine</m:NumberToWordsResult>
      </m:NumberToWordsResponse>
   </soap:Body>
</soap:Envelope>

但我得到“ORA-29266:end-of-body reached”错误并获取DBMS输出如下:

<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.dataaccess.com/webservicesserver/NumberConversion.wso">here</a></body>```
p3rjfoxz

p3rjfoxz1#

此端点不再支持http,而是使用https。
使用RapiAPI检测:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <m:NumberToWordsResponse xmlns:m="http://www.dataaccess.com/webservicesserver/">
      <m:NumberToWordsResult>four </m:NumberToWordsResult>
    </m:NumberToWordsResponse>
  </soap:Body>
</soap:Envelope>

相关问题