I try to do SOAP request with .pfx file and i got error like:
SOAP-ERROR: Parsing WSDL: Couldn't load from : failed to load external entity
my code look like that :
$this->api_url = "https://wsa.clalbit.co.il/CalcCampaignPremia.asmx?WSDL";
$certificate = dirname( __FILE__ ) . '/ws-hova.pfx';
$options = array(
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => 1,
'local_cert' => $certificate,
'stream_context' => stream_context_create( array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
) )
);
try {
$this->soap = new SoapClient( $this->api_url, $options );
} catch (SoapFault $e) {
echo $e->getMessage();
}
can't understand why it is not working.
thank's for any advice
The native PHP soap client class can not work with pfx certificates. You have to turn your pfx file into a pem file. For this purpose install the openssl toolkit and run the following command in your shell / command line interface.
openssl pkcs12 -in ws-hova.pfx -out ws-hova.pem -nodes -clcerts
After you 've done creating a pem certificate out of your pfx certificate you can simply use it with the PHP soap client.
$certificate = dirname( __FILE__ ) . '/ws-hova.pem';
$options = [
'cache_wsdl' => WSDL_CACHE_NONE,
'exceptions' => true,
'trace' => true,
'local_cert' => $certificate,
'authentication' => SOAP_AUTHENTICATION_DIGEST,
];
try {
$client = new SoapClient( $this->api_url, $options );
} catch (SoapFault $e) {
echo $e->getMessage();
}
This will do the trick. ;) Have fun.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.