I am currently using a calender system that has an API I can access with SOAP requests. It exists on an IIS server.
Initially I figured I could create an HTML page that that I would then have use Javascript to return the contents of the SOAP request - and my SOAP requests returns exactly what I want it to, but not in valid XML - it just displays on the screen (currently commented out below).
What I need to know is how do I get a page to return just the valid XML response (and no other tags, so it is recognized as XML)? Would PHP be better suited for this - or ASP?
My current javascript looks like this:
function soap() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'http://myserver/EMSAPI/', true);
//Todays Date now = new Date();
year = "" + now.getFullYear();
month = "" + (now.getMonth() + 1); if (month.length == 1) { month = "0" + month; }
day = "" + now.getDate(); if (day.length == 1) { day = "0" + day; }
hour = "" + now.getHours(); if (hour.length == 1) { hour = "0" + hour; }
minute = "" + now.getMinutes(); if (minute.length == 1) { minute = "0" + minute; }
second = "" + now.getSeconds(); if (second.length == 1) { second = "0" + second; }
todaydate = year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":" + second + ".000";
// build SOAP request
var sr =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
'<soap:Body>' +
'<GetAllBookings xmlns="http://DEA.EMS.API.Web.Service/">' +
'<UserName>EmsAPI</UserName>' +
'<Password>Mypass</Password>' +
'<StartDate>'+todaydate+'</StartDate>' +
'<EndDate>'+todaydate+'</EndDate>' +
'<BuildingID>36</BuildingID>' +
'<ViewComboRoomComponents>false</ViewComboRoomComponents>' +
'</GetAllBookings>' +
'</soap:Body>' +
'</soap:Envelope>';
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
ret = xmlhttp.responseText;
//$(document.body).append(ret);
}
}
}
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send(sr);
// send request
// ...
}
window.onload = function() { soap(); };
My HTML is very straight forward - it is a blank document besides including the javascript.
The problem is I'm using some software that cannot interface with the calender directly - and that software will only accept a valid XML response - so whatever page I write, it has to return just the pure XML so that way when I tell the software the page URL - it is given the XML response appropriately.
Just wondering what other ways there may be to go about this to get it to work. I apologize if the question is confusing - I can elaborate if needed.