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!

Authentication and access using UTL_HTTP

PK_UpNorthJul 7 2014 — edited Jul 10 2014

Using our intranet - everything is being done internally - I'm trying to use UTL_HTTP to access a web service and call a method that will take a specified XML file and upload it.   I'm using UTL_HTTP.SET_AUTHENTICATION and passing my network credentials.  We are using IIS.


If I  hit the web service with a browser using my credential there is no problem with authentication.  If I run the code using UTL_HTTP.SET_AUTHENTICATION passing my network credentials the response I get back is a 401.2 Authentication error.


Below is the relevant portion of the code, followed by a segment of the response. I would appreciate any insight into resolving the authentication issues.


  Dir_v       := 'DIR_PLSQL';
  FName_full  := 'GRD12239279_090614-1618.XML';

  FPath_v     := '
server\dir1\dir2\utlfile\plsql\';
  URL_v       := 'http://dev.Org.com/OrgfileXfer/Xfer.asmx/'
                 ||'SaveDocument?filepath='||FPath_v
                 ||'?filename='||FName_full;
  UTL_FILE.FGETATTR(Dir_v, FName_full, FExist, FLen, BSize);
  IF FExist THEN
    UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(TRUE);
    Req_v := UTL_HTTP.BEGIN_REQUEST(url => URL_v, method => 'POST');
    UTL_HTTP.SET_AUTHENTICATION(r => Req_v, username => 'domain\myuser',password => 'mypassword');
    UTL_HTTP.SET_HEADER(Req_v, 'Content-Type', 'text/xml; charset=utf-8');
    UTL_HTTP.SET_HEADER(Req_v, 'Content-Length', FLen);
    UTL_HTTP.WRITE_TEXT(Req_v, Dir_v||FName_full);
    Resp_v := UTL_HTTP.GET_RESPONSE(Req_v);
    DBMS_LOB.CREATETEMPORARY(ReadResp, TRUE);
    EndOFile := FALSE;
    LOOP
      EXIT WHEN EndOFile;
      BEGIN
        UTL_HTTP.READ_LINE(Resp_v, Buffer_v);
        IF LENGTH(Buffer_v) > 0 THEN
          DBMS_LOB.WRITEAPPEND(ReadResp, LENGTH(Buffer_v), Buffer_v);
        END IF;
        EXCEPTION WHEN UTL_HTTP.END_OF_BODY THEN
          EndOFile := TRUE;
      END;
    END LOOP;
    UTL_HTTP.END_RESPONSE(Resp_v);
    DBMS_OUTPUT.PUT_LINE(ReadResp);
    DBMS_LOB.FREETEMPORARY(ReadResp);
  END IF;



----






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IIS 8.5 Detailed Error - 401.2 - Unauthorized</title>
</head>
<body>
<div id="content">
<div class="content-container">
<h3>HTTP Error 401.2 - Unauthorized</h3>
<h4>You are not authorized to view this page due to invalid
authentication headers.</h4>
</div>



Thanks,

Paul

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 7 2014
Added on Jul 7 2014
12 comments
9,476 views