SOAP - PHP - 使用用户名/密码和证书登录

问题描述

我尝试创建一个 SOAP PHP 脚本,但我遇到了问题。 我有凭据和证书 x509。

$wsdl = 'https://e-licitatie.ro:8883/pub?wsdl';
$client = new SoapClient($wsdl,array(
  'local_cert' => 'cert.p12','soap_version' => SOAP_1_2,'Username' => 'xxxx','Password'=>'xxxx','trace' => 1,));

我收到此错误

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://e-licitatie.ro:8883/pub?wsdl' : Failed to load external entity "https://e-licitatie.ro:8883/pub?wsdl" in /home/adisonro/seap.adison.ro/index.PHP:10 Stack trace: #0 /home/adisonro/seap.adison.ro/index.PHP(10): SoapClient->SoapClient('https://e-licit...',Array) #1 {main} thrown in /home/adisonro/seap.adison.ro/index.PHP on line 10

我尝试了另一个具有相同结果的脚本。

$config['wsdl'] = 'https://e-licitatie.ro:8883/pub?wsdl';
$config['namespace'] = 'https://e-licitatie.ro:8883/pub'; 
$config['soap_options'] = array(
    // 'soap_version'=>SOAP_1_2,'exceptions'=>true,'trace'=>1,'cache_wsdl'=>WSDL_CACHE_NONE
);

$credentials = (object)array('Username' => 'xxxx','Password' => 'xxxx');
$auth_object = new SoapVar($credentials,SOAP_ENC_OBJECT);
$header =  new SoapHeader($config['namespace'],"SeapUserCredentials",$auth_object);

$client = new SoapClient($config['wsdl'],$config['soap_options']);

在文档中我有这个 XML,但我不明白它是如何工作的:

 <soapenv:Header>
 <SeapUserCredentials xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org">
 <Password
xmlns=“http://schemas.datacontract.org/2004/07/SICAP.Service.Integration">password</Password>
 <Username
xmlns=“http://schemas.datacontract.org/2004/07/SICAP.Service.Integration">username</Username>
 </SeapUserCredentials>
 </soapenv:Header>

谢谢!!!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)