码迷,mamicode.com
首页 > 其他好文 > 详细

crm2011 使用SOAP 查询单个记录 Retrieve

时间:2014-05-31 05:01:55      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:c   class   tar   http   a   ext   

function getServiceUrl() {
    var serverUrl = Xrm.Page.context.getServerUrl();
    if (serverUrl.match(/\/$/)) {
        serverUrl = serverUrl.substring(0, serverUrl.length - 1);
    }
    return serverUrl + "/XRMServices/2011/Organization.svc/web";
}

function Retrieve(entityName,entityId) {
      var request = "<s:Envelope xmlns:s=‘http://schemas.xmlsoap.org/soap/envelope/‘>"
      request += "<s:Body>"
      request += "<Retrieve xmlns=‘http://schemas.microsoft.com/xrm/2011/Contracts/Services‘ xmlns:i=‘http://www.w3.org/2001/XMLSchema-instance‘>"
      request += "<entityName>‘"+ entityName +"‘</entityName>"
      request += "<id>‘"+ entityId +"‘</id>"
      request += "<columnSet xmlns:a=‘http://schemas.microsoft.com/xrm/2011/Contracts‘>"
      request += "<a:AllColumns>true</a:AllColumns>"
      request += "<a:Columns xmlns:b=‘http://schemas.microsoft.com/2003/10/Serialization/Arrays‘ />"
      request += "</columnSet>"
      request += "</Retrieve>"
      request += "</s:Body>"
      request += "</s:Envelope>";

      var xmlAjax = new XMLHttpRequest();
      xmlAjax.open("POST", getServiceUrl(), true);
      xmlAjax.setRequestHeader("Accept", "application/xml, text/xml, */*");
      xmlAjax.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
      xmlAjax.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Retrieve");
      xmlAjax.onreadystatechange = function() {
          execresult(xmlAjax);
      };
      xmlAjax.send(request);
}

function execresult(ajax) {
    if (ajax.readyState == 4) {
        if (ajax.status == 200) {
            alert(ajax.responseXML);
        }
    }
}

crm2011 使用SOAP 查询单个记录 Retrieve,布布扣,bubuko.com

crm2011 使用SOAP 查询单个记录 Retrieve

标签:c   class   tar   http   a   ext   

原文地址:http://www.cnblogs.com/mfrbuaa/p/3761636.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!