zoukankan      html  css  js  c++  java
  • web方式AJAX调用

    

    var id =crmForm.all.new_productpricelevel_kz.DataValue[0].id
    var nsrsbh =crmForm.all.new_name.DataValue;
    //得到产品代码
    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\">" + 
    GenerateAuthenticationHeader() + 
    "  <soap:Body>" + 
    "    <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "      <entityName>new_productpricelevel_kz</entityName>" + 
    "      <id>"+id+"</id>" + 
    "      <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:AllColumns\" />" + 
    "    </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;
    
    var cpdm =resultXml.getElementsByTagName("q1:new_cpxmdm")[0].childNodes[0].nodeValue;
    
    
    // 得到 用户ID
    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\">" + 
    GenerateAuthenticationHeader() + 
    "  <soap:Body>" + 
    "    <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "      <Request xsi:type=\"WhoAmIRequest\" />" + 
    "    </Execute>" + 
    "  </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/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    
    var resultXml = xmlHttpRequest.responseXML;
    
    var userID=resultXml.getElementsByTagName("UserId")[0].childNodes[0].nodeValue;
    
     //得到部门ID
    
    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\">" + 
    GenerateAuthenticationHeader() + 
    "  <soap:Body>" + 
    "    <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "      <entityName>systemuser</entityName>" + 
    "      <id>"+userID+"</id>" + 
    "      <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:AllColumns\" />" + 
    "    </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;
    
    var bmid=resultXml.getElementsByTagName("q1:businessunitid")[0].childNodes[0].nodeValue
    
    //得到部门网站
     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\">" + 
    GenerateAuthenticationHeader() +
    "  <soap:Body>" + 
    "    <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "      <entityName>businessunit</entityName>" + 
    "      <id>"+bmid+"</id>" + 
    "      <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:AllColumns\" />" + 
    "    </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;
    webUrl =resultXml.getElementsByTagName("q1:websiteurl")[0].childNodes[0].nodeValue;
    var url=  webUrl .replace(";", "?");
    url +="<?xml version='1.0' encoding='UTF-8'?><MSG><REQHEAD><YWLX_DM>EDES.SERVICE.QUERY.QUERY_JFXX_BY_FWCP_AND_NSRSBH</YWLX_DM><TOKEN>wEPDwUJOTA5MDI0MzY0D2QWAmYPZBYCAgEPZBYEAgEPZBYCAgEPFQEUL0luY2x1ZGUvamF2YXNjcmlwdC9kAgMPZBYMAgEPZBYUZg8PFgo</TOKEN></REQHEAD><REQBODY><NSRSBH>"+nsrsbh+"</NSRSBH><FWCP_DM>"+cpdm+"</FWCP_DM></REQBODY></MSG>";
    
    
    xmlHttpRequest.Open("GET", url,false);
    
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    
    xmlHttpRequest.send(null);
    
    var resultXml = xmlHttpRequest.responseText;
    
      var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async="false";
      xmlDoc.loadXML(resultXml );
    var begindatevalue= xmlDoc.getElementsByTagName("QSRQ")[0].childNodes[0].nodeValue;
    begindatevalue =begindatevalue.replace(/-/g, '/ '); 
    
    var enddatevalue= xmlDoc.getElementsByTagName("JZRQ")[0].childNodes[0].nodeValue;
    enddatevalue=enddatevalue.replace(/-/g, '/ '); 
    var fwbh =xmlDoc.getElementsByTagName("FWBH")[0].childNodes[0].nodeValue;
    
    var cpmc =xmlDoc.getElementsByTagName("FWCP_MC")[0].childNodes[0].nodeValue;
    alert("办理产品:"+cpmc+"  起始时间:"+begindatevalue+"  截止时间:"+enddatevalue+"");
    
    crmForm.all.new_fwbh.DataValue=fwbh;
    crmForm.all.new_yxqq.DataValue = new Date( begindatevalue);
    crmForm.all.new_yxqz.DataValue= new Date( enddatevalue);
    
  • 相关阅读:
    查看.Net Framework版本的方法
    JS手机号码自动换位
    VS2008正版序列号
    ASP.NET对XML的操作
    JS宽高度
    下载某个网站的内容
    C#中如何将控件中表格数据导出到exeal文档中
    像素 厘米 英寸 换算
    编程经验点滴避免使用汉语拼音做变量名
    编程经验点滴避免在数据库访问函数中使用 try catch
  • 原文地址:https://www.cnblogs.com/hellohongfu/p/1789703.html
Copyright © 2011-2022 走看看