Hello,
I have problem using a soap call in Javascript. What I am trying to do is use the QueryMultipleSchedules message to evaluate the availability of a group of resources (stored in Array). I've fiddled a bit with the format of the fields (especially the dates), but the message now goes trough without errors. Only, the response is always empty. Whatever time block or resource I use, I get an empty xml response where I was expecting to see per sent resource GUID the availability status.
This is the code I use:
//get date parameters var Start = Xrm.Page.getAttribute("scheduledstart").getValue(); Start = Start.format("yyyy-MM-ddThh:mm:ss.sszzz"); var End = Xrm.Page.getAttribute("scheduledend").getValue(); End = End.format("yyyy-MM-ddThh:mm:ss.sszzz"); var Available = new Array(); Available[0] = "{619FDFC7-2D70-E111-B7D3-1CC1DE086845}"; var TimeCodes = 0; //assemble xml /*Generate Soap Body.*/ var soapBody = "<soap:Body>" +" <Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +" <Request xsi:type=\'QueryMultipleSchedulesRequest\'>" +" <ResourceIds>" + Available + "</ResourceIds>" + " <Start>" + Start + "</Start>" + " <End>" + End + "</End>" + " <TimeCodes>" + TimeCodes + "</TimeCodes>" + " </Request>" +" </Execute>" +"</soap:Body>"; alert (soapBody); /*Wrap the Soap Body in a soap:Envelope.*/ var soapXml = "<soap:Envelope " +" xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' " +" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" + GenerateAuthenticationHeader() + soapBody +"</soap:Envelope>"; /* Create the XMLHTTP object for the execute method.*/ var serverUrl = Xrm.Page.context.getServerUrl() + "/MSCRMservices/2007/crmservice.asmx"; var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST", serverUrl, false); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute"); /* Send the XMLHTTP object. */ xmlhttp.send(soapXml); alert (xmlhttp.responseXml.xml);
Which gives me this response:
<?xml version="1.0"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ExecuteResponse xmlns="http://schemas.microsoft.com/crm/2007/WebServices"><Response xsi:type="QueryMultipleSchedulesResponse"><TimeInfos/></Response></ExecuteResponse></soap:Body></soap:Envelope>
No matter what resources or time values I use, the result always comes up empty, no error, just empty.
Can anyone tell me what I'm doing wrong?
Thanks,
Rimmer