24.11.2009, 09:56 | #1 |
Участник
|
CrmService.Create из java script
и сново я с вопросами.... наковырял вот такой вот кодик в MSDN
// Prepare values for the new contact. var firstname = "Jesper"; var lastname = "Aaberg"; var donotbulkemail = "true"; var address1_stateorprovince = "MT"; var address1_postalcode = "99999"; var address1_line1 = "23 Market St."; var address1_city = "Sammamish"; var authenticationHeader = GenerateAuthenticationHeader(); // Prepare the SOAP message. var xml = "<?xml version='1.0' encoding='utf-8'?>" + "<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'>"+ authenticationHeader+ "<soap:Body>"+ "<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+ "<entity xsi:type='contact'>"+ "<address1_city>"+address1_city+"</address1_city>"+ "<address1_line1>"+address1_line1+"</address1_line1>"+ "<address1_postalcode>"+address1_postalcode+"</address1_postalcode>"+ "<address1_stateorprovince>"+address1_stateorprovince+"</address1_stateorprovince>"+ "<donotbulkemail>"+donotbulkemail+"</donotbulkemail>"+ "<firstname>"+firstname+"</firstname>"+ "<lastname>"+lastname+"</lastname>"+ "</entity>"+ "</Create>"+ "</soap:Body>"+ "</soap:Envelope>"; // Prepare the xmlHttpObject and send the request. var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Create"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xHReq.setRequestHeader("Content-Length", xml.length); xHReq.send(xml); // Capture the result var resultXml = xHReq.responseXML; // Check for errors. var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); } // Open new contact record if no errors. else { var contactid = resultXml.selectSingleNode("//CreateResult"); window.open("/sfa/conts/edit.aspx?id={"+contactid.nodeTypedValue+"}"); } а вот ссылочка на него http://msdn.microsoft.com/en-us/library/cc677070.aspx запись в стоке xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); конечно же менял на свою смотрел ответ от сервера приходит пустой .... хотя ответ должен быть соответственно ошибка возникает вот тут var contactid = resultXml.selectSingleNode("//CreateResult"); window.open("/sfa/conts/edit.aspx?id={"+contactid.nodeTypedValue+"}"); в чем может быть дело в самом запросе ? |
|
|
Похожие темы | ||||
Тема | Ответов | |||
gustafwesterlund: Create replacement entities | 0 | |||
mscrm4ever: CRM Form Script Loader | 0 | |||
Быстродействие CrmService | 16 | |||
аутентификация crmService | 2 | |||
Обращение к CrmService | 23 |
|