zoukankan      html  css  js  c++  java
  • mscrm4.0 用js调用Webservice

    var ORG_NAME="xteam";
    function retrieve(entityName,entityId,attributeName){
        
    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\">" + 
        
    "  <soap:Header>" + 
        
    "    <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
        
    "      <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>" + 
        
    "      <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">"+ORG_NAME+"</OrganizationName>" + 
        
    "      <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">00000000-0000-0000-0000-000000000000</CallerId>" + 
        
    "    </CrmAuthenticationToken>" + 
        
    "  </soap:Header>" + 
        
    "  <soap:Body>" + 
        
    "    <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
        
    "      <entityName>"+entityName+"</entityName>" + 
        
    "      <id>"+entityId+"</id>" + 
        
    "      <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\">" + 
        
    "        <q1:Attributes>" + 
        
    "          <q1:Attribute>"+attributeName+"</q1:Attribute>" + 
        
    "        </q1:Attributes>" + 
        
    "      </columnSet>" + 
        
    "    </Retrieve>" + 
        
    "  </soap:Body>" + 
        
    "</soap:Envelope>" + 
        
    "";
        
        
    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        
        xmlHttpRequest.Open(
    "POST""/mscrmservices/2007/CrmService.asmx"false);
        xmlHttpRequest.setRequestHeader(
    "SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
        xmlHttpRequest.setRequestHeader(
    "Content-Type""text/xml; charset=utf-8");
        xmlHttpRequest.setRequestHeader(
    "Content-Length", xml.length);
        xmlHttpRequest.send(xml);
        
    var resultXml = xmlHttpRequest.responseXML;
        
    return resultXml;
    }

    var resultXml= retrieve("systemuser","a37eeb60-54ae-df11-97a3-00155d612b04","fullname");

    alert(resultXml.xml);
  • 相关阅读:
    做好技术的量的累积,实现业绩的质的飞跃|专访宜信财富技术负责人刘宝剑
    深入理解MySQL索引
    程序的一生:从源程序到进程的辛苦历程
    Serializable详解(1):代码验证Java序列化与反序列化
    关于Java序列化的问题你真的会吗?
    Dubbo源码解析之SPI(一):扩展类的加载过程
    [C#] 命令总线模式
    C#构造函数在继承时必须要求与父类型构造函数入参相同怎么办?
    如何通过JavaScript构建Asp.net服务端控件
    Javascript iframe交互并兼容各种浏览器的解决方案
  • 原文地址:https://www.cnblogs.com/seerlin/p/1979471.html
Copyright © 2011-2022 走看看