问题
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