I have wsdl file and 3rd party api. We want to fetch data from 3rd party and show on my website we have username and password but we are new in soap api. how to connect with authentication in soap api and fetch data from wsdl file.
We are trying to fetch but this error is showing :
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/examin8/public_html/CI/soap/client.php:42
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://119.73....', 'urn://119.73.25...', 1, 0)
#1 /home/examin8/public_html/CI/soap/client.php(42): SoapClient->__soapCall('RealTimePriceDa...', Array)
#2 /home/examin8/public_html/CI/soap/sevice.php(11): client->getDetails(Array) #3 {main} thrown in /home/examin8/public_html/CI/soap/client.php on line 42
PHP code :
<?php
class client{
public function __construct() {
$param = array("location" => "https://119.73.253.101:9514/emcdsvc/",
"uri" => "urn://119.73.253.101:9514/emcdsvc/",
"trace" => 1);
$this->instance = new SoapClient(NULL,$param);
$auth_param = new stdClass();
$auth_param->username = "env_solution";
$auth_param->password = "Password1";
$header_param = new SoapVar($auth_param, SOAP_ENC_OBJECT);
$header = new SoapHeader("soap", "authenticate", $header_param, FALSE);
$this->instance->__setSoapHeaders(array($header));
try {
$date_array = array("date" => date("dd-mm-yyyy"));
$result = $this->instance->__soapCall("RealTimePriceDataWebService", $date_array);;
print_r($result);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
$client = new client;