Skip to Main Content

API, CLI, SDK & Automation

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Calling SOAP via UTL_HTTP and OAuth2

GJoobSep 26 2024

I am trying to call a Workday SOAP web service from Oracle. I am able to do it from Postman, but anything I try in Oracle just returns the same 500 error message:

"<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wd="urn:com.workday/bsvc"><faultcode>SOAP-ENV:Client.validationError</faultcode><faultstring>Invalid request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>"

This is a SOAP call using OAuth2 and I have the access token (Bearer) which is sent as a header.

Does anyone know what I am doing wrong or missing with this code below?

DECLARE

l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_buffer VARCHAR2(32767);
l_access_token VARCHAR2(32767);
l_soap_body VARCHAR2(32767) := '<?xml version="1.0" encoding="utf-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"><env:Body><wd:Get_Cost_Centers_Request xmlns:wd="urn:com.workday/bsvc" wd:version="v43.0"><wd:Response_Filter><wd:As_Of_Effective_Date>2024-09-23</wd:As_Of_Effective_Date><wd:As_Of_Entry_DateTime>2024-09-23T21:33:15</wd:As_Of_Entry_DateTime><wd:Page>1</wd:Page><wd:Count>100</wd:Count></wd:Response_Filter><wd:Response_Group><wd:Include_Reference>true</wd:Include_Reference><wd:Include_Cost_Center_Data>true</wd:Include_Cost_Center_Data></wd:Response_Group></wd:Get_Cost_Centers_Request></env:Body></env:Envelope>';
l_url VARCHAR2(32767) := 'https://<workday-tenant>';

BEGIN
-- Get the access token
l_access_token := F_GET_TOKEN;

-- Prepare and send the SOAP request
l_http_request := UTL_HTTP.begin_request(l_url, 'POST', 'HTTP/1.1');
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_soap_body));
UTL_HTTP.set_header(l_http_request, 'Authorization', 'Bearer ' || l_access_token);
UTL_HTTP.write_text(l_http_request, l_soap_body);

l_http_response := UTL_HTTP.get_response(l_http_request);
BEGIN
LOOP
UTL_HTTP.read_text(l_http_response, l_buffer);
DBMS_OUTPUT.put_line(l_buffer); -- Output the response
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
NULL;
END;

UTL_HTTP.end_response(l_http_response);

END;

Many thanks.

Comments
Post Details
Added on Sep 26 2024
0 comments
129 views