从 Oracle pl/sql 调用 Soap Web 服务出现错误

问题描述 投票:0回答:1

当我调用 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:已到达正文末尾”错误并得到如下 DBMS 输出:

<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.dataaccess.com/webservicesserver/NumberConversion.wso">here</a></body>```
oracle web-services plsql soap
1个回答
0
投票

该端点不再支持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>
© www.soinside.com 2019 - 2024. All rights reserved.