Hi all,
I'm having an issue with calling webservices in a SAPUI5 project. My question is the following:
- I have an url like this: http://example.sap.corp:1111/SAPHost/?wsdl
- Through SOAPUI I was able to insert this url, get all the webservices inside the WSDL and called two differents webservices.
- After this I've tried to write the JavaScript code to call one webservice but I'm not getting any response.
- Here is the code
soap: function() { | ||
// build SOAP request
var params =
'<?xml version="1.0" encoding="utf-8"?>' +
'<SOAP-ENV:Envelope ' +
'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' +
'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:SAPControl="urn:SAPControl" xmlns:SAPCCMS="urn:SAPCCMS" ' +
'xmlns:SAPHostControl="urn:SAPHostControl" xmlns:SAPOscol="urn:SAPOscol" ' +
'xmlns:SAPDSR="urn:SAPDSR">' +
'<SOAP-ENV:Body>' +
'<SAPHostControl:GetCIMObject>' +
'<aArguments>' +
'<item>' +
'<mKey>EnumerateInstances</mKey>' +
'<mValue>SAP_MetricValue?Interval=00000000000100.000000:000&StartTime=0</mValue>' +
'</item>' +
'</aArguments>' +
'</SAPHostControl:GetCIMObject>' +
'</SOAP-ENV:Body>' +
'</SOAP-ENV:Envelope>';
var xmlhttp = new XMLHttpRequest();
//Call the webservice GetCIMObject
var url ="http://example.sap.corp:1111/SAPHost/GetCIMObject";
xmlhttp.open('POST', url, true,'user','password');
xmlhttp.setRequestHeader("Access-Control-Allow-Origin","*");
xmlhttp.setRequestHeader("Access-Control-Allow-Methods", "POST");
xmlhttp.setRequestHeader('Access-Control-Allow-Headers','Origin, X-Requested-With, Content-Type, Accept');
xmlhttp.withCredentials=true;
xmlhttp.send(params);
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{ alert(xmlhttp.responseText); }
};
},
The variable xmlhttp is always with the readyState = 0 and with the status = undefined.
- Does anyone know what is missing or wrong in the code? Thanks in advance!