php soap 复杂请求 上海资信 金融p2p <faultstring>Error cannot find parameter <faultstring>Function ' not found

要点

1 soap 链接 https的接口的时候 dorequest 方法需要重写

2 需要需要登录的话 dorequest 也要加入cookie

3 注意要加入wsdl规范  new soapclient('wsdl.txt',options)

wsdl.txt 从soap接口服务器下载

问题:

1 群友(php群 50194090)问soap接口的问题,,上海资信soap 。比较复杂的接口 需要登录 vpn,登录后输入网址,得到soap 接口的真实地址

2 、

先登录

$url = 'https://vpn.shanghai-cis.com.cn/+webvpn+/index.html';$post_data = array(
'tgroup' =>'',
'next' =>'',
'tgcookieset' =>'',
'username'=>'aaa',
'password'=>'bbb',
'Login'=>'登录',
);
$headers = array(
"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding:gzip, deflate",
"Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
"Connection:keep-alive",
"Cookie:webvpnx=; webvpnlogin=1; webvpn_state=; csc_next=; webvpnlogin=1; webvpnLang=en",
"Host:vpn.shanghai-cis.com.cn",
"Referer:https://vpn.shanghai-cis.com.cn/+CSCOE+/logon.html",
"User-Agent:Mozilla/5.0 (Windows NT 6.1; rv:39.0) Gecko/20100101 Firefox/39.0"
);
$link = curl($url,$headers,$post_data);//var_dump($link);
$reg = '/webvpn=\s*([^;]+);/is';
echo $link;
if (preg_match_all($reg,$link['header'],$p))
$cookiestr = implode(';',$p[1]);
function curl($url,$headers=array(),$post_data=''){$ch = curl_init();curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);  // 从证书中检查SSL加密算法是否存在curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);curl_setopt($ch, CURLOPT_HEADER, true);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_TIMEOUT, 30);$response = curl_exec($ch);$errmsg = curl_error($ch);$pos = strpos($response,"\r\n\r\n");return array('code'=>curl_getinfo($ch,CURLINFO_HTTP_CODE),'header'=>substr($response,0,$pos),'body'=>substr($response,$pos+4),'error'=>$errmsg);//curl_close($ch);
}

链接 soap

       $context = stream_context_create( array ('ssl' => array ('verify_peer' => false,'allow_self_signed' => true),));$options['stream_context'] = $context;$client = new SoapClientAuth('wsdl.txt', array('location' => 'https://vbbb/batchcredit?wsdl', // 设置server路径'uri' => 'https://vpn.ddd/batchcredit?wsdl','login' => 'ccc', // HTTP auth login'password' => 'ddd', // HTTP auth password'trace'=>true,'targetNamespace'=>'http://webservice.creditreport.p2p.sino.com/','stream_context'=>$context));$client->__setCookie('webvpn',$cookiestr);var_dump($client);

返回方法,和测试方法

     $param1 = array('orgcode'=>'Q100000000','secret'=>'bbbbb','plate'=>'1','certtype'=>'0','certno'=>'111','name'=>'李亚','reason'=>'06','createtype'=>'0');
        var_dump($client->__getFunctions());//var_dump($client->__soapCall());$ret = $client->queryCredit($param1);

最重要的soap 类

<?php
/***    SoapClientAuth for accessing Web Services protected by HTTP authentication*    Author: tc*    Last Modified: 04/08/2011*    Update: 14/03/2012 - Fixed issue with CURLAUTH_ANY not authenticating to NTLM servers*    Download from: http://tcsoftware.net/blog/**    Copyright (C) 2011  tc software (http://tcsoftware.net)**    This program is free software: you can redistribute it and/or modify*    it under the terms of the GNU General Public License as published by*    the Free Software Foundation, either version 3 of the License, or*    (at your option) any later version.**    This program is distributed in the hope that it will be useful,*    but WITHOUT ANY WARRANTY; without even the implied warranty of*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*    GNU General Public License for more details.**    You should have received a copy of the GNU General Public License*    along with this program.  If not, see <http://www.gnu.org/licenses/>.*//*** SoapClientAuth* The interface and operation of this class is identical to the PHP SoapClient class (http://php.net/manual/en/class.soapclient.php)* except this class will perform HTTP authentication for both SOAP messages and while downloading WSDL over HTTP and HTTPS.* Provide the options login and password in the options array of the constructor.** @author tc* @copyright Copyright (C) 2011 tc software* @license http://opensource.org/licenses/gpl-license.php GNU Public License* @link http://php.net/manual/en/class.soapclient.php* @link http://tcsoftware.net/*/class SoapClientAuth extends SoapClient{public $Username = NULL;public $Password = NULL;/**** @param string $wsdl* @param array $options*/function SoapClientAuth($wsdl, $options = NULL){@stream_wrapper_unregister('https');@stream_wrapper_unregister('http');stream_wrapper_register('https', 'streamWrapperHttpAuth');stream_wrapper_register('http', 'streamWrapperHttpAuth');if($options){$this->Username = $options['login'];streamWrapperHttpAuth::$Username = $this->Username;$this->Password = $options['password'];streamWrapperHttpAuth::$Password = $this->Password;}parent::SoapClient($wsdl, ($options?$options:array()));@stream_wrapper_restore('https');@stream_wrapper_restore('http');}function __doRequest($request, $location, $action, $version) {$headers = array('User-Agent: PHP-SOAP','Content-Type: text/xml; charset=utf-8','SOAPAction: "' . $action . '"','Content-Length: ' . strlen($request),'Expect: 100-continue','Connection: Keep-Alive');$this->__last_request_headers = $headers;$ch = curl_init($location);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_POST, TRUE);curl_setopt($ch, CURLOPT_POSTFIELDS, $request);curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);curl_setopt($ch, CURLOPT_FAILONERROR, FALSE);curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);curl_setopt($ch, CURLOPT_USERPWD, $this->Username . ':' . $this->Password);global $cookiestr;curl_setopt($ch, CURLOPT_COOKIE,'webvpn='.$cookiestr);//curl_setopt($ch, CURLOPT_SSLVERSION, 3);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);curl_setopt($ch, CURLOPT_VERBOSE, TRUE);curl_setopt($ch, CURLOPT_CERTINFO, TRUE);$response = curl_exec($ch);if(($info = curl_getinfo($ch)) && $info['http_code']==200)return $response;else if($info['http_code']==401)throw new Exception ('Access Denied', 401);else if(curl_errno($ch)!=0){throw new Exception(curl_error($ch), curl_errno($ch));}elseprint_r($info);echo $info['http_code'];throw new Exception('Error', $info['http_code']);}}class streamWrapperHttpAuth{public static $Username = NULL;public static $Password = NULL;private $path = NULL;private $position = 0;private $buffer = NULL;private $curlHandle = NULL;public function stream_close(){if($this->curlHandle)curl_close ($this->curlHandle);}public function stream_open($path, $mode, $options, &$opened_path){$this->path = $path;$response = $this->postRequest($this->path);$this->buffer = ($response!==FALSE?$response:NULL);$this->position = 0;return $response!==FALSE;}public function stream_eof(){return $this->position>strlen($this->buffer);}public function stream_flush(){$this->position = 0;$this->buffer = NULL;}public function stream_read($count){if($this->buffer){$data = substr($this->buffer, $this->position, $count);$this->position += $count;return $data;}return FALSE;}public function stream_write($data){return ($this->buffer?TRUE:FALSE);}public function stream_seek($offset, $whence = SEEK_SET){switch($whence){case SEEK_SET:$this->position = $offset;break;case SEEK_CUR:$this->position += $offset;break;case SEEK_END:$this->position = strlen($this->buffer) + $offset;break;}return TRUE;}public function stream_tell(){return $this->position;}public function stream_stat(){return array('size' => strlen($this->buffer));}public function url_stat($path, $flags){$response = $this->postRequest($path);return array('size' => strlen($response));}protected function postRequest($path, $authType = CURLAUTH_ANY){$this->curlHandle = curl_init($path);curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, TRUE);curl_setopt($this->curlHandle, CURLOPT_FOLLOWLOCATION, TRUE);if(streamWrapperHttpAuth::$Username){curl_setopt($this->curlHandle, CURLOPT_HTTPAUTH, $authType);curl_setopt($this->curlHandle, CURLOPT_USERPWD, streamWrapperHttpAuth::$Username . ':' . streamWrapperHttpAuth::$Password);}//curl_setopt($this->curlHandle, CURLOPT_SSLVERSION, 3);curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);//curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYHOST, 2);$response = curl_exec($this->curlHandle);if(($info = curl_getinfo($this->curlHandle)) && $info['http_code']==200){if(curl_errno($this->curlHandle)==0){return $response;}elsethrow new Exception(curl_error($this->curlHandle), curl_errno($this->curlHandle));}else if($info['http_code']==401){ // Attempt NTLM Auth only, CURLAUTH_ANY does not work with NTMLif($authType!=CURLAUTH_NTLM)return $this->postRequest($path, CURLAUTH_NTLM);else{throw new Exception ('Access Denied', 401);}}else if(curl_errno($this->curlHandle)!=0){throw new Exception(curl_error($this->curlHandle), curl_errno($this->curlHandle));}elsethrow new Exception('Error', $info['http_code']);return FALSE;}}
?>

php soap https 登录 复杂请求 上海资信 金融p2p Error cannot find parameter faultstringFunction ' not found相关推荐

  1. PostMan怎样携带登录信息请求后台接口防止出现无法访问资源问题

    场景 前后端分离的项目. 前端在登录后请求后台的接口. 在使用postman进行测试后台接口时如果直接通过url进行访问 会提示认证失败,无法访问系统资源 注: 博客: https://blog.cs ...

  2. 无法打开登录所请求的数据库DbName 。登录失败。 用户 'IIS APPPOOL\DefaultAppPool' 登录失败。 的解决方案...

    转自:http://www.cnblogs.com/chsword/archive/2009/09/05/1561067.html 个问题是应用程序连接池的问题.网上有些朋友说是Temp文件夹的权限的 ...

  3. 【转】无法打开登录所请求的数据库 xxxx。登录失败。 用户 'xxxxx' 登录失败。...

    无法打开登录所请求的数据库 "xxxx".登录失败. 用户 'NT AUTHORITY\SYSTEM' 登录失败. 转载于:https://www.cnblogs.com/fran ...

  4. 无法打开登录所请求的数据库 sa。登录失败。 用户 sa 登录失败。

    今天新建个项目,写了个简单的页面,居然出现了这样的错误: 无法打开登录所请求的数据库 "Albums".登录失败.  用户 'NT AUTHORITY\SYSTEM' 登录失败.网 ...

  5. 深入理解HTTPS及在iOS系统中适配HTTPS类型网络请求(上)

    2019独角兽企业重金招聘Python工程师标准>>> 深入理解HTTPS及在iOS系统中适配HTTPS类型网络请求 一.引言 本篇博客主要讨论如何在客户端与服务端之间进行HTTPS ...

  6. Swift - 使用SwiftHTTP通过HTTPS进行网络请求,及证书的使用

    (本文代码已升级至Swift3) 一,证书的生成,以及服务器配置 参考我前面写的这篇文章:Tomcat服务器配置https双向认证(使用keytool生成证书) 文章详细介绍了HTTPS,SSL/TL ...

  7. Swift - 使用Alamofire通过HTTPS进行网络请求,及证书的使用

    (本文代码已升级至Swift3) 我原来写过一篇文章介绍如何使用证书通过SSL/TLS方式进行网络请求(Swift - 使用URLSession通过HTTPS进行网络请求,及证书的使用),当时用的是 ...

  8. java web 使用https_如何在Web应用程序中实现HTTPS登录页面?

    小编典典 首先,您需要为服务器启用SSL.对于Tomcat,您需要生成一个openSSL密钥库,并将以下连接器添加到server.xml: keystoreFile="mykeystore& ...

  9. java 登录 https_java – 如何在Web应用程序中实现HTTPS登录页面?

    首先,您需要为您的服务器启用SSL.对于Tomcat,您需要生成一个openSSL密钥库,并将以下连接器添加到server.xml: keystoreFile="mykeystore&quo ...

最新文章

  1. 计算机基础知识_2020年河北省高职单招计算机基础知识和实践技能培训
  2. C#_完整的RSA操作类
  3. UIScrollView的代理方法(delegate)
  4. python中itertools的用法_python中的itertools的使用详解
  5. 五轴加工的RTCP技术
  6. HTTP之缓存 Cache-Control
  7. 渗透测试入门24之渗透测试参考书、课程、工具、认证
  8. Android 内核的开发“顽疾”如何解决?
  9. 修改mysql root的秘密
  10. oracle本地没装 配置,数据库--oracle安装配置(本地安装的步骤及各种问题解决方案)...
  11. Clover 驱动文件夹_四叶草Clover相关
  12. 批处理访问服务器共享文件夹,批处理设置文件访问权限的方法分享
  13. RoadRunner软件初步使用教程
  14. 干货!基于信息瓶颈理论的神经元竞争初始化策略
  15. 罗技F710 无线手柄在ROS下的配置使用总结
  16. 【PAT乙级】1020 月饼
  17. 在Silverlight 2 beta1中使用IronPython等动态语言
  18. mysql sysdatabases_未能在 sysdatabases 中找到数据库 aa1xxxx 所对应的条目。没有找到具有该名称的条目...
  19. 查看linux 系统 服务器型号
  20. Android4.1.0实战教程---自动阅读小说

热门文章

  1. 【毕业设计】基于STM32的智能台灯设计 物联网 电子信息 APP远程控制
  2. 项目依赖关系分析中的数据结构
  3. 【mysql】drop、truncate和delete的区别
  4. 亿级用户体量,千万级日活用户,《王者荣耀》高并发背后的故事!
  5. POJ - 1077 Eight(A∗算法)
  6. 如何修改树莓派系统时间
  7. 光场视差与深度的关系(lytro深度计算公式)
  8. 摄影教室:数码摄影区域曝光法实用教程
  9. Dijkstra算法和Floyd算法对比分析
  10. 在高数中学到的sinc函数有两种定义