php调用webservice接口示例

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.1.54/EFWebS/EFWebService.asmx?WSDL");
 2 $context = $_POST["context"];
 3 // $soapclient = new soapclient("http://192.168.1.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;

 

转载于:https://www.cnblogs.com/h5kang/p/7831352.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值