PHP Talking with Exchange getting SOAP-ERROR: Parsing WSDL: - php

Im trying to communicate with Exchange using SOAP. But i have got a popular problem.
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://123.456.78.9:444/EWS/Services.wsdl' : failed to load external entity "https://123.456.78.9:444/EWS/Services.wsdl"
There is nothing wrong with the url, because it can be opened in browser.
I know, this question has been asked many time, but I still get no correct answer. I really appreciate your help.
And here is my little code.
try {
ini_set('display_errors', true); //does not help
ini_set("soap.wsdl_cache_enabled", "0");//does not help
error_reporting(E_ALL); //does not help
$client = new SoapClient(URL_EXCHANGE, array(
"login" => USER_EXCHANGE,
"password" => PASS_EXCHANGE)
);
return $client;
} catch (\SoapFault $exception) {
echo $exception->getMessage();
}

Related

SOAP-ERROR: Parsing WSDL: Couldn't load from : Document is empty

I have check every configuration is perfect like, SOPA, CURL, XML, libxml in php.ini file. But I am getting issue. I don't know what is the issue. It's working on local machine but when i upload on server and check then it's not working. I am trying to integrate dynamic nav api using NTLMSoapClient but it's not working in server.
Please see Below Code
$product = new NTLMSoapClient(PRODUCT_URL);
/*$params_d = array('filter' => array(
),
'setSize' => 2);*/
$result = $product->ReadMultiple();
$productData = $result->ReadMultiple_Result->WebItems;
Please help me if you know any solution
This error message is really unspecific and could just mean that curl returned false, luckily you can use curl_error to find out what exactly went wrong. In my implementation it looked like this.
$this->buffer = curl_exec($this->ch);
if (curl_errno($this->ch)) {
$error = curl_error($this->ch);
throw new Exception('CURL error: ' . $error);
}

SOAP webservice with PHP: could not connect to host

Please note that after much research I decided to write here since I couldn't pin-point the problem. Although it exists widely on the net. Sorry for that.
I'm trying to get a response using SOAP (see code below):
<?php
$param = array(
'USERID'=>'some_user',
'PASSWORD'=>'some_pwd',
'MARKETTYPE'=>'333',
'INSTRUMENTTYPE'=>'C'
);
$url = 'https://www.x/x/x/x.serviceagent?wsdl';
try
{
$soap_client = new SoapClient($url);
$soap_client->providedFunction($param);
} catch (SoapFault $e) {
echo $e->getMessage();
}
?>
Note that this code is on my local wamp server. (I also tried it online on a beta site)
When I refresh the php file, I get the following 'Could not connect to host'.
I appreciate any help given.
Thanks

Could not connect to host soap exception

I am using SOAP in a php script to call a web service from a Linux Centos 6 server. In this week I have been getting could not connect to host error from soapCall method. Of course this exception does not happen all the time but I see this exception most of the time, for example if I call soapCall 5 times, this error happens 3 times. My code is as below and I have not changed it at all for some months but recently it gets this error most of the time.
$wsdl="http://x.x.x.x:x/gw/services/Service?wsdl";
//Set key as HTTP Header
$aHTTP['http']['header'] = "key:" .$key ."\r\n";
$context = stream_context_create($aHTTP);
try
{
$client = new SoapClient($wsdl,array("soap_version" => SOAP_1_2,'trace' => 1,"stream_context" => $context));
}
catch(Exception $e)
{
return "something";
}
//I make $parametrs
try
{
$res = $client->__soapCall("send",array($parametrs));
}
catch(Exception $e)
{
print_r($e->getMessage()); //Most of the time it prints could not connect to host
}
I have read most answers to related questions here but my problem has not been solved. Also I added
ini_set("soap.wsdl_cache_enabled", "0");
ini_set("soap.wsdl_cache_ttl","0");
but nothing changed. I searched a lot about the reason and I found something about SSL but I have not found exact solution.
It must be mentioned that I can see the wsdl URL in browser and I have it's ping.

SOAP-ERROR: Parsing WSDL (PHP Version 5.6.17)

Really hoping someone can help with this as I just can't seem to resolve this issue.
I am having great difficulty with getting the code below to work on my website.
The purpose of the script is to return car lengths based on a provided registration number.
The problem is when I move this over to my live environment the script simply won't work. Please can anyone suggest a possible resolution? I don't understand why It works absolutely fine in the development environment but when I attempt to run it on my main site I get the following error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://website.com/CarLengthChecker.asmx?WSDL' : failed to load external entity "https://website.com/CarLengthChecker.asmx?WSDL"
<?php
$carReg = "0000000";
try{
$opts = array(
'http'=>array(
'user_agent' => 'PHPSoapClient'
)
);
$context = stream_context_create($opts);
$client = new SoapClient ('https://wesite.com/CarLengthChecker.asmx?WSDL',
array('stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_NONE));
$result = $client->GetVehicleDetails(array(
'VRM' => $carReg,
));
print_r($result);
}
catch(Exception $e){
echo $e->getMessage();
}
?>
I can access the WSDL address from a browser on the live server just not from the script.
I have checked the PHP settings on live and can confirm that both OpenSSL & SOAP
are enabled.
The resolution I found for this was to use the nusoap library (www.sourceforge.net/projects/nusoap). This problem may have been specific to our to live server environment but I would recommend attempting it if you are experiencing similar issues.

SOAP error encoding external reference in PHP

I am trying to use a function from SOAP, which will fetch details about a specific news item. The problem is that I don't get the expected results, just a a strange error. I am using the built-in SOAP client in PHP5.
My error is:
Fatal error: Uncaught SoapFault
exception: [Client] SOAP-ERROR:
Encoding: External reference
'https://newsclient.omxgroup.com/cdsPublic/viewDisclosure.action?disclosureId=379485&messageId=454590'
in
/home/********/public_html/********/updatenews3.php:15
My code is:
<?php
$login = '***';
$password = '***';
$client = new SoapClient(
'https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl',
array(
'login' => $login,
'password' => $password
));
$param = array('lastPublicationId' => 361825);
$result = $client->fetchNews($param);
?>
The error is the same for all lastPublicationId, where a result is found. It seems as if PHP is trying to load a link, which is found somewhere in the XML-reply (the URL, which is in the error message), and can't access it. Even though I have googled this a lot, I can't find any solution. The only thing I can find is that this seems to have been reported as a bug in a previous version of PHP, but the error refers to PHP 5.2.2 Since I'm using PHP 5.2.9, I'm thinking it can't be that. I'm suspecting the &-character to be the cause of this error?
The WSDL-file can be found here: https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl
Does somebody know this error, and know of any solution?
It's possible that the XML being returned by $client->fetchNews($param); isn't being escaped properly - there seems to be an unescaped & in the URL which is shown in the error message.
Best thing is probably to check exactly what XML is being returned, by turning on tracing and printing the last response:
$client = new SoapClient(
'https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl',
array(
'login' => $login,
'password' => $password,
'trace' => 1
));
$param = array('lastPublicationId' => 361825);
try {
$result = $client->fetchNews($param);
}
catch (SoapFault $sf) {
print '<pre>';
// print the exception
print_r($sf);
// print the XML response
print $client->__getLastResponse();
}
A workaround (if the server is returning invalid XML) is to use code similar to the above to catch the exception. You can then manually get at the XML returned (using __getLastResponse()), and clean it up yourself (e.g. using htmlenties or a regexp), before returning it and using it in the rest of your application.

Categories