SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from - php

Using Plesk 12.5 and PHP 7.0.2 I get the error:
SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://<IP ADDRESS>:9443/Configuration?wsdl' : failed to load external entity "https://<IP ADDRESS>:9443/Configuration?wsdl" in <PHP FILE>:51 Stack trace: #0 <PHP FILE>(51): SoapClient->SoapClient('https://<IP FILE>', Array) #1
It works using PHP 5.3 from the OS, but and PHP from Plesk I get the above error.
PHP-SOAP, XML, is installed.
The code I am using is:
try {
$configClient = new soapclient("https://{$node["host"]}:{$node["port"]}/Configuration?wsdl",
array('login' => $node["user"],
'password' => $node["pass"],
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
)
);
$configResponse = $configClient->enableALLProductFeatures();
} catch (SoapFault $exception) {
echo "Problem..... : ";
echo $exception;
}

Resolved by stream_context options. My code now looks like the following:
$context = stream_context_create(array(
'ssl' => array('verify_peer' => false, 'verify_peer_name'=>false, 'allow_self_signed' => true)
));
try {
$configClient = new soapclient("https://{$node["host"]}:{$node["port"]}/Configuration?wsdl",
array('login' => $node["user"],
'password' => $node["pass"],
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'stream_context' => $context
)
);
$configResponse = $configClient->enableALLProductFeatures();
} catch (SoapFault $exception) {
echo "Problem..... : ";
echo $exception;
}

Try debug your connection with curl:
curl -v --user "<login>:<password>" --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:<action>" --data #<file_name> <url_of_the_soap_web_service>

Related

SOAP-ERROR: Parsing WSDL: Couldn't load from: failed to load external entity

I am using an external SOAP API, and I am getting this error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://servis.turkiye.gov.tr/services/g2g/kdgm/uetdsarizi?wsdl' : failed to load external entity "https://servis.turkiye.gov.tr/services/g2g/kdgm/uetdsarizi?wsdl" "
The real problem is that sometimes it works just fine. For example, whenever I get this error, I just retype the same code into the page containing my script, and it works temporarily, then I get this error again.
This is my code :
<?php
try{
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
ini_set('display_errors','On');
$soapclient = new SoapClient('https://servis.turkiye.gov.tr/services/g2g/kdgm/uetdsarizi?wsdl',
array(
'trace' => 1,
'exceptions' => true,
'login' => '***',
'password' => '***',
'stream_context' => $context
)
);
$param=array('wsuser'=>[
'kullaniciAdi'=>'***',
'sifre'=>'***'],
'uetdsSeferReferansNo'=>'1'
);
$response =$soapclient->bildirimOzeti($param);
$vars = $response -> return;
$sonucKodu = $vars -> sonucKodu;
echo $sonucKodu."\n";
print var_dump($response);
}catch(Exception $e){
echo var_dump($e->getMessage());
echo var_dump($client->__getLastRequest());
echo var_dump($client->__getLastResponse());
}
?>
I need to get rid of this error permanently.

Fatal Error in Awin API - Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from

I have a very serious issue. I am working witht he API - https://ui.awin.com/awin/affiliate/250615?region=gb and after login into that, i found the api documentation and also php api client zip.
I then downloaded this client zip, updated all my api details and when i run - http://202.131.107.107/searchcycle/ps_client.php , I always get error as below -
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://v6.core.com.productserve.com/ProductServeService.wsdl' : failed to load external entity "http://v6.core.com.productserve.com/ProductServeService.wsdl" in /var/www/html/searchcycle/classes/class.php5Client.php:57 Stack trace: #0 /var/www/html/searchcycle/classes/class.php5Client.php(57): SoapClient->SoapClient('http://v6.core....', Array) #1 /var/www/html/searchcycle/classes/class.php5Client.php(95): Php5Client->__construct(Object(stdClass)) #2 /var/www/html/searchcycle/classes/class.ClientFactory.php(60): Php5Client::getInstance(Object(stdClass)) #3 /var/www/html/searchcycle/ps_client.php(29): ClientFactory::getClient() #4 {main} thrown in /var/www/html/searchcycle/classes/class.php5Client.php on line 57
Can someone please help me in this what is missing from my side.
Add optional SSL parameters.
How to solve:
// options for ssl in php 5.6.5
$opts = array(
'ssl' => array(
'ciphers' => 'RC4-SHA',
'verify_peer' => false,
'verify_peer_name' => false
)
);
// SOAP 1.2 client
$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) // Magic happens here
);
$wsdlUrl = $url . '?WSDL';
$oSoapClient = new SoapClient($wsdlUrl, $params);
Please check this question, you would find something useful.

PHP SoapClient Cannot process the message because the content type 'text/xml;

I cannot connect to webservice and send/receive data
Error
HTTP,Cannot process the message because the content type 'text/xml;
charset=utf-8' was not the expected type 'application/soap+xml;
charset=utf-8'.
Code
$parameters = [
'UserName' => 12324,
'Password' => 432123,
'Bill_Id' => 153585611140,
'Payment_Id' => 8560103,
];
$url="https://bill.samanepay.com/CheckBill/BillStateService.svc?wsdl";
$method = "VerifyBillPaymentWithAddData";
$client = new SoapClient($url);
try{
$info = $client->__call($method, array($parameters));
}catch (SoapFault $fault){
die($fault->faultcode.','.$fault->faultstring);
}
Notice : not work Soap version 1,1 and other resolve sample for this error in stackoverflow.
You could try
$url = "https://bill.samanepay.com/CheckBill/BillStateService.svc?wsdl";
try {
$client = new SoapClient($url, [
"soap_version" => SOAP_1_2, // SOAP_1_1
'cache_wsdl' => WSDL_CACHE_NONE, // WSDL_CACHE_MEMORY
'trace' => 1,
'exception' => 1,
'keep_alive' => false,
'connection_timeout' => 500000
]);
print_r($client->__getFunctions());
} catch (SOAPFault $f) {
error_log('ERROR => '.$f);
}
to verify that your method name is correct.
There you can see the method
VerifyBillPaymentWithAddDataResponse VerifyBillPaymentWithAddData(VerifyBillPaymentWithAddData $parameters)
Next is to check the Type VerifyBillPaymentWithAddData and if the parameter can be an array.
Also you could test to call the method via
$client->VerifyBillPaymentWithAddData([
'UserName' => 12324,
'Password' => 432123,
'Bill_Id' => 153585611140,
'Payment_Id' => 8560103,
]);
or yours except the additional array
$info = $client->__call($method, $parameters);
EDIT:
Assuming to https://stackoverflow.com/a/5409465/1152471 the error could be on the server side, because the server sends an header back that is not compatible with SOAP 1.2 standard.
Maybe you have to use an third party library or even simple sockets to get it working.
Just use the following function. Have fun!
function WebServices($function, $parameters){
$username = '***';
$password = '***';
$url = "http://*.*.*.*/*/*/*WebService.svc?wsdl";
$service_url = 'http://*.*.*.*/*/*/*WebService.svc';
$client = new SoapClient($url, [
"soap_version" => SOAP_1_2,
"UserName"=>$username,
"Password"=>$password,
"SOAPAction"=>"http://tempuri.org/I*WebService/$function",
'cache_wsdl' => WSDL_CACHE_NONE, // WSDL_CACHE_MEMORY
'trace' => 1,
'exception' => 1,
'keep_alive' => false,
'connection_timeout' => 500000
]);
$action = new \SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', "http://tempuri.org/I*WebService/$function");
$to = new \SoapHeader('http://www.w3.org/2005/08/addressing', 'To', $service_url);
$client->__setSoapHeaders([$action, $to]);
try{
return $client->__call($function, $parameters);
} catch(SoapFault $e){
return $e->getMessage();
}
}

SOAP-ERROR: Parsing WSDL: Couldn't load from (Working on SOAPUI bu not on my Ubuntu)

I am facing a weird problem. I am trying to consume a specific webservice, which you can see on:
https://api-hom.amil.com.br/operadora/tiss/LoteGuias/soap/v30301?wsdl
Through the soap client I can consume and receive result properly.
But, when I am consuming through my PHP code I got "SOAP-ERROR: Parsing Schema: can't import schema from 'https://api-hom.amil.com.br/ssg/wsdl/tissWebServicesV3_03_01.xsd?serviceoid=477f074ec66fee8e74f533c102c312ff&servdocoid=477f074ec66fee8e74f533c102c31348'" error
My code is below:
public function webservice_request($soap_request, $partner) {
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'trace' => 1,
'soap_version' => SOAP_1_1,
'exceptions'=> true,
'encoding' => 'UTF-8',
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE,
'cache_wsdl' => WSDL_CACHE_NONE
)
));
// Transformando em Array
$json = \GuzzleHttp\json_encode($soap_request);
$xml = \GuzzleHttp\json_decode($json);
$client = null;
try
{
$client = new \SoapClient($partner->webservice_url, array('trace' => true, 'stream_context' => $context));
$result = $client->__call('tissLoteGuias_Operation', array($xml));
return $this->check_response($result, 'NORMAL', $client);
} catch (\Exception $e) {
if (isset($client) == false) {
return $this->check_response($e, 'WSDL_ERROR', null);
} else {
return $this->check_response($e, 'FAULT', $client);
}
}
}
Observations:
[1] The problem happens on line:
$client = new \SoapClient($partner->webservice_url, array('trace' => true, 'stream_context' => $context));
[2] when I execute the same code on my Macbook it works, but in my Ubuntu server and Ubuntu Desktop it isn't working.
What I am doing wrong?

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter and cant connect to SoapClient

I am new to web services and might be doing small mistake somewhere.I am trying to connect and use a WebService with PHP and SoapClient and getting a following error:
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in /www/1/html/webservices/tuev-nord-ass/soapclientconnect.php
WSDL link:
http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl
My code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('soap.wsdl_cache_ttl', '0');
$wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
$options = array('trace' => true);
$client = new SoapClient($wsdl,
array(
'user' => 'tülsenbeck',
'password' => 'tülsenbeck',
'corporate_group_id' => '101',
'dealer_number' => 'INT31303',
'dms_id' => 'A13T2D19',
'dms_image_url' => '',
'dms_keepalive_url' => '',
'dms_followup_url' => '',
)
);
//Returns list of available SOAP functions described in the WSDL for the Web service.
var_dump($client->__getFunctions());
//some parameters to send
$result = $client>Login('user','password','corporate_group_id','dealer_number','dms_id','dms_image_url','dms_keepalive_url','dms_followup_url');
var_dump($result);
?>
You completely mess the function arguments up.
$options = array('trace' => true);
$params = array(
'user' => 'deshmukh',
'password' => 'deshmukh',
'corporate_group_id' => '101',
'dealer_number' => 'INT31303',
'dms_id' => 'A13T2D19',
'dms_image_url' => '',
'dms_keepalive_url' => '',
'dms_followup_url' => ''
);
$client = new SoapClient($wsdl, $options); // options!!!
$result = $client->Login($params); // params!!!
Now it replies with “Zugangsdaten sind nicht gültig,” I guess you’ll go further yourself.
MfG

Categories