PJF: How To Call SOAP Web Service From Standalone Webpage Using Java script or XmlHttpRequest (Doc ID 2263951.1)

Last updated on MAY 09, 2017

Applies to:

Oracle Fusion Project Foundation Cloud Service - Version 11.1.11.1.0 and later
Information in this document applies to any platform.

Goal

We are able to call the web service operations from the Soap UI client successfully. When trying to call the SOAP web service from a standalone webpage using the java script and XmlHttpRequest, getting the cross-domain error because the web service is in a different domain. Even though the profile options setup to support CORS.

No 'Access-Control-Allow-Origin' header is present on the requested resource

Profile options are setup to support CORS, as mentioned in the documentation below -
https://docs.oracle.com/cloud/farel11/projectcs_gs/FAIGR/FAIGR1985238.htm#FAIGR1985238

Here are the profile option values that has been set at the Site-level -
Allowed Domains = *
CORS: Access-Control-Max-Age = 3600
CORS: Access-Control-Allow-Methods = OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE
CORS: Access-Control-Allow-Headers = Accept, Accept-Encoding, Cache-Control, Content-MD5, Content-Type, If-Match, If-None-Match, Origin, User-Agent, X-HTTP-Method-Override, X-Requested-By, Authorization
CORS: Access-Control-Allow-Credentials = True

Javascript code
=========
function fusionCall() {
var xmlString = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/projects/foundation/projectDefinition/publicService/maintainProjectV2/types/">' +
'<soapenv:Header/>' +
'<soapenv:Body>' +
'<typ:getProject>' +
'<typ:projectId>300000007142993</typ:projectId>' +
'</typ:getProject>' +
'</soapenv:Body>' +
'</soapenv:Envelope>'

var username = 'myusername', password = 'mypassword';
$.soap({
url: 'https://<Your URL Details>/pjfProjectDefinition/ProjectDefinitionPublicServiceV2',
HTTPHeaders: {
Authorization: 'Basic ' + btoa(username + ':' + password)
},
method: 'getProject',
data: xmlString,
}).done(function (data, textStatus, jqXHR) {
console.log('done...');
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log('fail...');
});
}

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms