Soap authentification failed

给你一囗甜甜゛ 提交于 2019-12-12 05:45:19

问题


I'm used to writing PHP code for a SOAP call and this is my code

<?php
    $client = new SoapClient("http://www.fma.fr/webservices_comparateurs/tarification_sante_comparateurs.asmx?wsdl");
   $param = array('NomUtilisateur' => 'XXXXXX','MotDePasse' => 'XXYYZZ','ContenuDuMessage' => '');
   $values = $client->TariferSante($param);

    var_dump($values);

?>

when i execute the script I get an authentification error message:

object(stdClass)#2 (1) { ["TariferSanteResult"]=> string(109) "err_authentification" }

the used parameters are true, you can try with this link: http://www.fma.fr/webservices_comparateurs/tarification_sante_comparateurs.asmx?op=TariferSante


回答1:


updated Answer : i tried this code and it worked

$options = array(
    'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
    'style'=>SOAP_RPC,
    'use'=>SOAP_ENCODED,
    'soap_version'=>SOAP_1_1,
    'cache_wsdl'=>WSDL_CACHE_NONE,
    'connection_timeout'=>15,
    'trace'=>true,
    'encoding'=>'UTF-8',
    'exceptions'=>true,

);

class TariferSante {

    public $nomUtilisateur;
    public $motDePasse;
    public $contenuDuMessage;
}
$client = new SoapClient("http://www.fma.fr/webservices_comparateurs/tarification_sante_comparateurs.asmx?wsdl",$options);

$param = new TariferSante();
$param->nomUtilisateur = "XXXXXXX";
$param->motDePasse = "XXYYZZ";
$param->contenuDuMessage = "";
$values = $client->TariferSante($param);
echo "Request".htmlspecialchars($client->__getLastRequest());

var_dump($values);



回答2:


i had the same problem with Teradata Soap, i think it needs Basic Authorisation over http - my solution was:

  $opts = array();
  $opts['login'] = 'username';
  $opts['password'] = 'secretpassword';
  $opts['trace'] = 1;
  $opts['authentication'] = SOAP_AUTHENTICATION_BASIC;
  $url = "https://example.com/vx?wsdl";
  $client = new SoapClient($url, $opts);

i got it working with that.

Check my discussion here: Soap Header with Authorization Basic in native PHP



来源:https://stackoverflow.com/questions/37908373/soap-authentification-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!