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

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);
}

Related

FileMaker XML Web Publishing XML error

$FM_CONNECT = array(
'DB_FILE' => 'webaccess'
);
require_once "__app/dbConnect/FM.php";
require_once "__app/environmentSettings/environmentSettings.php";
$layout = 'webAccess';
$findCommand =& $fm->newFindCommand($layout);
$findCommand->addFindCriterion('AccountName', $_POST['username']);
$result = $findCommand->execute();
if(FileMaker::isError($result)){
FMExit(array(
'code' => 1,
'mes' => $result->getMessage()
));
}
$records = $result->getRecords();
When I try send some request to FileMaker server it return.
"XML error: Not well-formed (invalid token) at line 1"
I haven't change the code for a few weeks and I didn't see this error before.
Has anyone else experienced something like this?
This looks like FileMaker php api. If it is the case, you are missing the connection. If you just omitted the connection code from your code (since you get the error from the server), look at your request and check that XML is well formed. I can't check the request as you did not post it.
Make sure the web publishing engine is started and working. I faced this problem already and in my case the WPE was stopped suddenly. I started the WPE from the admin console and it was fine.

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

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();
}

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 request failing. Server or code issue?

I'm trying to setup a data request for a site, but, am running into a problem when trying to pull the data.
I tested the url and credentials using http://www.soapclient.com/soaptest.html and it works perfectly so I know the service is up and the correct credentials are being entered, but, when using the code below, I'm given the following error;
Fatal error: Uncaught SoapFault exception: [Invalid Login] in...
The full code (except generalized URL) that I'm using to make the request is;
<?php
$client2 = new SoapClient("http://www.example.com/api/soap.php?wsdl", array('trace'=> true));
$results2 = $client2->boxInfo(array(
"customer" => 'XBLK',
"size" => "four",
"price" => "twenty"));
echo "<pre>";
var_dump($client2-> __getLastRequestHeaders());
var_dump($client2-> __getLastRequest());
var_dump($client2-> __getLastResponseHeaders());
var_dump($client2-> __getLastResponse());
var_dump($results2);
echo "</pre>";
?>
As I'm new to these calls, I'm not sure if I missed something with the SOAP installation when I updated php (I verified it's installed and enabled) or if I've just been staring at the code so long that I'm simply missing something obvious.
It's a client issue if it works elsewhere. Try using an object to hold the parameters instead of an array:
$params = new stdClass();
$params->customer = 'XBLK';
$params->size = 'four';
$params->price = 'twenty';
$results2 = $client2->boxInfo($params);

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