Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Transfer Timeout using UTL_HTTP to certain Endpoints

CInglezSTCMar 8 2022

Hi.
I am having trouble trying to consume a simple SOAP webservice using UTL_HTTP (I've tried APEX_WEB_SERVICE too, with the same results).
I am using Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
This is the function I am trying:

create or replace FUNCTION STC_WS_SOAP_UTL RETURN varchar2


AS


  l_envelope      VARCHAR2(32767);
  l_result        VARCHAR2(32767) := null;


   http_req        UTL_HTTP.req;
   http_resp       UTL_HTTP.resp;


BEGIN


    -- Build a SOAP document appropriate for the web service.


    l_envelope := '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nfes="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4">
   <soap:Header/>
   <soap:Body>
      <nfes:nfeDadosMsg>
         <consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"><tpAmb>2</tpAmb><cUF>35</cUF><xServ>STATUS</xServ></consStatServ>
      </nfes:nfeDadosMsg>
   </soap:Body>
</soap:Envelope>';


    UTL_HTTP.set_wallet('file:C:\Oracle\wallet_xxxxxxx', 'XXXXXXXX');
    http_req := UTL_HTTP.begin_request('https://homologacao.nfe.fazenda.sp.gov.br/ws/nfestatusservico4.asmx', 'POST', 'HTTP/1.1');
    UTL_HTTP.set_header(http_req, 'Accept-Encoding', 'gzip,deflate');
    UTL_HTTP.set_header(http_req, 'Content-Type', 'application/soap+xml;charset=UTF-8');
    UTL_HTTP.set_header(http_req, 'SOAPAction', 'http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF');
--    UTL_HTTP.set_header(http_req, 'transfer-encoding', 'chunked');
    UTL_HTTP.set_header(http_req, 'Content-Length', '408');
--    UTL_HTTP.set_header(http_req, 'Host', 'homologacao.nfe.fazenda.sp.gov.br');
    UTL_HTTP.set_header(http_req, 'Connection', 'Keep-Alive');
    UTL_HTTP.set_header(http_req, 'User-Agent', 'Apache-HttpClient/4.5.5 (Java/16.0.1)');
--    UTL_HTTP.set_transfer_timeout(http_req, 300);
    UTL_HTTP.write_text(http_req, l_envelope);
    
    http_resp := UTL_HTTP.get_response(http_req);
    UTL_HTTP.read_text (http_resp, l_result);
    UTL_HTTP.end_response (http_resp);


    RETURN l_result;

END;

When I try to consume the webservice on other endpoints it works. The problem is: I need to run it on this endpoint. The error is:

ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1288
ORA-29276: transfer timeout
ORA-06512: at "SYS.UTL_HTTP", line 651
ORA-06512: at "SYS.UTL_HTTP", line 1278
ORA-06512: at "SETICIS.STC_WS_SOAP_UTL", line 37

When I post the following request on SoapUI, it works:

POST https://homologacao.nfe.fazenda.sp.gov.br/ws/nfestatusservico4.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF"
Content-Length: 408
Host: homologacao.nfe.fazenda.sp.gov.br
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/16.0.1)


<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nfes="http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4">
   <soap:Header/>
   <soap:Body>
      <nfes:nfeDadosMsg>
         <consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"><tpAmb>2</tpAmb><cUF>35</cUF><xServ>STATUS</xServ></consStatServ>
      </nfes:nfeDadosMsg>
   </soap:Body>
</soap:Envelope>

I have already set ACE, wallet, etc.
Any help would be appreciated.
Thanks in advance

Comments
Post Details
Added on Mar 8 2022
24 comments
4,833 views