In PHP: I am getting an error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.xxxx.asmx?WSDL' : failed to load external entity "http://xxx.xxxx.asmx?WSDL"
My code is:
<?php
header('Content-Type: text/plain');
if (!class_exists('SoapClient')) {
die ("You haven't installed the PHP-Soap module.");
}
ini_set('max_execution_time', 1);
try {
$options = array(
'soap_version' => SOAP_1_2,
'exceptions' => true,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE
);
$client = new SoapClient('http://xxx.xxxx.asmx?WSDL', $options);
// Note where 'CreateIncident' and 'request' tags are in the XML
$results = $client->CreateIncident(
array(
'FirstName' => 'gyaan',
'LastName' => 'p',
'Email' => '[email protected]',
'QueryProductClass' => 'QueryProductClass',
'ChannelCode' => 12,
'CampaignCode' => 234,
'Lob' => 'Lob',
'PackageName' => 'SEONI',
'PackageCode' => 'SMP',
'TravelYear' => 2012,
'TravelMonth' => 06,
'TravelDay' => 29,
'CityOfResidence' => 'Jabalpur',
'ncidentNotes' => 'testing ignor this',
'MobilePhone' => '1234567890',
'DepartureCity' => 'bangalore',
'NoOfDaysTravel' => '3 Days',
'VendorName' => 'TEST HIQ'
)
);
}
catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
?>
Please tell me where i am making mistake i am new in WSDL and soap
If you want to use that on localhost, then use WAMP.
Then click on tray icon>PHP Services> and there enable the followings:
p.s. some free web-hosting may not have those options
I got the same error
Could not connect to the Magento WebService API: SOAP-ERROR: Parsing WSDL: Couldn't load from 'example.com/api/soap/?wsdl' : failed to load external entity "example.com/api/soap/?wsdl"
and my issue resolved once I update my Magento Root URL to
example.com/index.php/api/soap/?wsdl
Yes, I was missing index.php that causes the error.
Enable all these from php.ini configuration file
extension=php_openssl.dll
extension=php_curl.dll
extension=php_xmlrpc.dll
Try this:
$Wsdl = 'http://xxxx.xxx.xx/webservice3.asmx?WSDL';
libxml_disable_entity_loader(false); //adding this worked for me
$Client = new SoapClient($Wsdl);
//Code...
you can use this option for call soap with wdsl :
$opts = array(
'http' => array(
'user_agent' => 'PHPSoapClient'
)
);
$context = stream_context_create($opts);
$soapClientOptions = array(
'stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_NONE
);
$wsdlUrl = 'your wsdl url';
$soapClient = new SoapClient($wsdlUrl, $soapClientOptions);
$result = $soapClient->VerifyTransaction($refNum, $MerchantCode);
I solved this on my WAMP setup by enabling the php_openssl
extension, since the URL I was loading from used https://
.
Similar error as well. Realized I had an .htpasswd setup for the particular host. Uncommented it from the .htaccess file and worked fine.
Try adding this piece of code. It worked for me.
$opts = array(_x000D_
'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false)_x000D_
);_x000D_
// SOAP 1.2 client_x000D_
$params = array ('encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 180, 'stream_context' => stream_context_create($opts) );_x000D_
$url = "http://www.webservicex.net/globalweather.asmx?WSDL";_x000D_
_x000D_
try{_x000D_
$client = new SoapClient($url,$params );_x000D_
}_x000D_
catch(SoapFault $fault) {_x000D_
echo '<br>'.$fault;_x000D_
}
_x000D_
add the dns entry to your system hosts file
for example:http://aaa.com/service.asmx?WSDL
you can get the aaa.com's ip address with ping
and then add to the hosts file
I had this problem and it took me hours to figure out. The mainly reason of this error is the SoapClient cannot stream the web service file from the host. I uncommented this line "extension=php_openssl.dll" in my php.ini file and it works.
I got the same error and I solved it looking for the soap settings in the php.ini file and changing soap.wsdl_cache_enabled=1 to soap.wsdl_cache_enabled=0
I had exactly the same error message. In my case, making an entry in my /etc/hosts
file (on the server hosting the service) for the target server referenced in the WSDL fixed it.
Kind of a strangely worded error message..
As mentioned in earlier responses, this error can occur when interacting with a SOAP service over an HTTPS connection, and an issue is identified with the connection. The issue may be on the remote end (invalid cert) or on the client (in case of missing CA or PEM files). See http://php.net/manual/en/context.ssl.php for all possible SSL context settings. In my case, setting the path to my local certificate resolved the issue:
$context = ['ssl' => [
'local_cert' => '/path/to/pem/file',
]];
$params = [
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($context),
'cache_wsdl' => WSDL_CACHE_NONE, // eliminate possible issue from cached wsdl
];
$client = new SoapClient('https://remoteservice/wsdl', $params);
Source: Stackoverflow.com