javascript部分代码:
1 var context = \'<?xml version="1.0" encoding="utf-8"?><ufinterface efserverid="\'+efid+\'" eftype="EFsql" sqlstr="select * from Customer where cCusCode=\\'\' + $(".ccode").val() + \'\\' and cCusDefine2=\\'\' + $(".pass").val() + \'\\'" proc="Query" efdebug="1" ></ufinterface>\'; 2 $.post("php/inventory.php", { 3 context: context 4 }, function(str) { 5 var xmlStrDoc = null; 6 if(window.DOMParser) { // Mozilla Explorer 7 parser = new DOMParser(); 8 xmlStrDoc = parser.parseFromString(str, "text/xml"); 9 } else { // Internet Explorer 10 xmlStrDoc = new ActiveXObject("Microsoft.XMLDOM"); 11 xmlStrDoc.async = "false"; 12 xmlStrDoc.loadXML(str); 13 } 14 console.log(xmlStrDoc); 15 if(xmlStrDoc.getElementsByTagName(\'ufinterface\')[0].getAttribute("succeed") == 1) { 16 sessionStorage.setItem("ccusname", xmlStrDoc.getElementsByTagName(\'head\')[0].childNodes[0].getAttribute("cCusName")); 17 sessionStorage.setItem("ccuscode", xmlStrDoc.getElementsByTagName(\'head\')[0].childNodes[0].getAttribute("cCusCode")); 18 sessionStorage.setItem("priceGrade", xmlStrDoc.getElementsByTagName(\'head\')[0].childNodes[0].getAttribute("iCostGrade")); 19 sessionStorage.setItem("loginCode", xmlStrDoc.getElementsByTagName(\'head\')[0].childNodes[0].getAttribute("cCusCode")); 20 sessionStorage.setItem("loginPass", xmlStrDoc.getElementsByTagName(\'head\')[0].childNodes[0].getAttribute("cCusDefine2")); 21 sessionStorage.setItem("cInvoiceCompany", xmlStrDoc.getElementsByTagName(\'head\')[0].childNodes[0].getAttribute("cInvoiceCompany"));//开票单位 22 $.post("php/session.php", {code: $(".ccode").val()}, function(data) { 23 window.location.href = "orderPage.php"; 24 }); 25 } else { 26 alert("账号或密码错误"); 27 outLogin(); 28 } 29 });
php部分代码:
1 $soapclient = new soapclient("http://10.0.51.54/EFWebS/EFWebService.asmx?WSDL"); 2 $context = $_POST["context"]; 3 // $soapclient = new soapclient("http://192.168.15.33/EFWebS/EFWebService.asmx?WSDL"); 4 // print_r($soapclient->__getFunctions()); //可调用的函数 5 // print_r($soapclient->__getTypes()); //获取服务器上数据类型 6 header(\'content-type:text/html;charset=utf-8\'); 7 $mparam = array("Content-Type"=> "application/x-www-form-urlencoded","context"=>"{$context}"); 8 $mresult = $soapclient->U8WebXML($mparam); 9 $mresult = get_object_vars($mresult); 10 // print_r($mresult[\'U8WebXMLResult\']); 11 $xmlResult = $mresult[\'U8WebXMLResult\']->any; 12 echo $xmlResult;