zoukankan      html  css  js  c++  java
  • php调用webservice接口

     1 <?php
     2     header("Content-type: text/html; charset=utf-8");  
     3     $webservice_url = "http://test.com/test.svc?wsdl";//webservice地址
     4     $client = new SoapClient($webservice_url);
     5     
     6     // echo '<pre/>';
     7     // echo '<xmp>';
     8     // print_r( $client->__getFunctions ()); 
     9     // echo "相关的数据结构
    ";
    10     // print_r($client->__getTypes () ); 
    11     // echo '</xmp>';
    12     // exit;
    13     
    14     
    15     //该传参已做优化,参数都为必需值        
    16     $param = array(
    17         'name'=>'test',
    18         'cart'=>array(
    19             'PaymentInfo'=>array(
    20                 'CardId'=>'AAABBBCCC'
    21                 'CardPassword'=>'123456'
    22             ),
    23             'SplitItems'=>array(
    24                 '0'=>array(
    25                     'Items'=>array(
    26                         '0'=>array(
    27                             'Product'=>array(
    28                                 'Amount'=>1,
    29                                 'SKU'=>'11111'
    30                             )
    31                         ),
    32                         '1'=>array(
    33                             'Product'=>array(
    34                                 'Amount'=>1,
    35                                 'SKU'=>'111111'
    36                             )
    37                         )
    38                     )
    39                 )
    40             ),
    41         )
    42     );
    43     $time_ago = microtime(true);
    44     try{
    45         $arr = $client->__soapCall('index',array('parameters' => $param));//调用其中index方法
    46     }catch(Exception $e){
    47         $arr = $e->getMessage();    
    48     }
    49     $time_end = microtime(true);
    50     echo 'webservice执行时间差为:'.($time_end-$time_ago).'s';
    51     print_r($arr);
    52     exit;
  • 相关阅读:
    kafka作业详解(HTML+Nginx+ngx_kafka_module+Kafka)
    Zookeeper知识点总结
    用CocoaPods做iOS程序的依赖管理
    iOS 正则表达式
    iOS 自定义UITabBarController
    iOS 同一UILabel改变数字的颜色
    iOS 自定义字体
    iOS 修改状态条颜色
    iOS 过滤掉HTML标签
    iOS UILabel自适应
  • 原文地址:https://www.cnblogs.com/wanghaokun/p/5856878.html
Copyright © 2011-2022 走看看