I've been at this for the better part of 12 hours now. I keep getting connection issues. This is a non https request, though I have tried enabling the open_ssl.dll and other suggestions.
I can view the WSDL just fine in a browser
http://www.soapclient.com/interop/interopTest.html also returns values for me.
my code:
<?php
function doWebService()
{
########################################################################
# Do some SOAP / Call a Web Service
$soap_url = 'http://WEBSITE/WebServices/PublicAPI.asmx?WSDL';
//$soap_url = 'x.x.x.x/WebServices/PublicAPI.asmx?WSDL';
$sh_param = array(
'username' => 'admin_username',
'password' => 'admin_password');
$soap_client = new SoapClient($soap_url);
$test = $soap_client->Authenticate($sh_param);
echo $test . "\nDone";
/*
try
{
$soap_url = 'http://WEBSITE/WebServices/PublicAPI.asmx?WSDL';
//$soap_url = 'x.x.x.x/WebServices/PublicAPI.asmx?WSDL';
$sh_param = array(
'username' => 'admin_username',
'password' => 'admin_password');
$soap_client = new SoapClient($soap_url);
$test = $soap_client->Authenticate($sh_param);
echo $test . "\nDone";
}
catch (Exception $e)
{
echo "<pre>";
print_r($e);
echo "</pre>";
exit;
}
*/
}
doWebService();
?>
It fails on the $soap_client = new SoapClient($soap_url) line.
I've tried changing between PHP 4.0, 5.2, 5.3. 5.4 and 6.0. None help.
I've tried enabling
extension=php_curl.dll
extension=php_openssl.dll
extension=php_soap.dll
This is on my website using the host:
ntchosting.com
trying to access the API on another.
Actual error code
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://WEBSITE.com/WebServices/PublicAPI.asmx?WSDL' : failed to load external entity "http://WEBSITE.com/WebServices/PublicAPI.asmx?WSDL" in /home/www/MY_WEBSITE.com/main_php/_test_public_api.php:13 Stack trace: #0 /home/www/MY_WEBSITE.com/main_php/_test_public_api.php(13): SoapClient->SoapClient('http://WEBSITE...') #1 /home/www/MY_WEBSITE.com/main_php/_test_public_api.php(50): doWebService() #2 {main} thrown in /home/www/MY_WEBSITE.com/main_php/_test_public_api.php on line 13
All I want to do is be able to use the API to retrieve data and provide a sync between what I've got and another established software. Just does not seem to be remotely easy whenever I try and get my hands wet.
thanks,
jc
I managed to find out that the outbound connections were being blocked. Forced the IP to an allow list and things are working a bit better.
Related
This is my code:
$this->options = [
"login" => $username,
"password" => $password
];
try {
$this->request = new SoapClient('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl', $this->options);
} catch(Exception $e) {
throw new Exception($e->getMessage());
}
And this is the error message:
Fatal error: Uncaught Exception: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl' : failed to load external entity "https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl"
Any idea how I can fix this error?
[UPDATE]
I can get functions with this code:
$wsdl = file_get_contents('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl');
But this code still gets error:
SoapClient('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl', $this->options);
try from command line:
wget https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl
or
php -r '$a = new SoapClient("https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl"); var_dump($a);'
Maybe resource id not available from tour host
To handle SOAP exceptions, you can give this answer a try. Following code is standalone code which is returning a SOAP response.
$params = array(
"login" => "USERNAME",
"password" => "PASSWORD"
);
try {
$client = new SoapClient('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsesya?wsdl', array($params));
} catch(Exception $e) {
throw new Exception($e->getMessage());
}
To List all available SOAP functions:
echo " List of available SOAP functions <br/><pre>"; var_dump($client->__getFunctions()); echo "</pre>";
To List all available SOAP types:
echo "List of SOAP types <br/><pre>"; var_dump($client->__getTypes()); echo "</pre>";
This answer has an explanation about how to access any available SOAP function.
I am new to SOAP API and WSDL. I had this project to use the SOAP API and I used this code from one of the stackoverflow answers. But when I am running this, I am getting this error.
Fatal error: Uncaught SoapFault exception: [HTTP] Forbidden in 'directory' Stack trace: #0 [internal function]: SoapClient->__doRequest('...') #1 directory): SoapClient->__call('method', Array) #2
Here is my code:
<?php
try{
$wsdl_url = 'API';
$client = new SoapClient($wsdl_url);
} catch (SoapFault $e) {
echo 'Error in Soap Connection : '.$e->getMessage();
}
$params = array(
'LBID' => '1',
'YearID' => '23',
'SectorId' => '3',
'Password' => 'password'
);
$result= $client->getProjectDetails($params);
print_r($result);
?>
I am able to access the api by directly putting it on address bar. The soap connection is established, no errors there. But this error is showing on the method calling line, $result= $client->getProjectDetails($params);
I don't know what this error is, I tried searching the forums but couldn't get any idea about this. Can anyone help?
I made one of SOAP web service on local machine. I call with a SOAP client via the some.wsdl file, work fine. But I try to use full host-URL http://flow.local/soap/some.wsdl
The index.php (with SOAP) client:
<?php
//Here change the client to 'some wsdl' / 'http://flow.local/soap/some.wsdl'
$client = new SoapClient("http://flow.local/soap/some.wsdl",
array('soap_version' => SOAP_1_2,'trace' => 1 ));
var_dump($client->__getFunctions());
$return = $client->__soapCall("hello",array("World"));
echo("\nReturning value: ".$return);
Here is the soap.php
<?php
function hello($someone)
{
return "Hello " . $someone . "! - With WSDL";
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("http://flow.local/soap/some.wsdl",
array('soap_version' => SOAP_1_2));
$server->addFunction("hello");
$server->handle();
And of course I have a wsdl schema file.
When I use full URL http://flow.local/soap/some.wsdl returns with:
"Fatal error: Uncaught SoapFault exception: [VersionMismatch] Wrong Version!"
Else work fine.
Win10Pro, WAMP server, PHP version 7.2.18.
Im new to Five9 i got some sample code in GitHub (https://github.com/kielerrr/Five9 ) which i went though the code and i passed the credentials into API but i get the following error
"Fatal error: Uncaught Error: Class 'SoapClient' not found in C:\xampp\htdocs\Five9-master\includes\Five9.php:20 Stack trace: #0 C:\xampp\htdocs\Five9-master\contacts\getContactRecords.php(12): f9->__construct() #1 {main} thrown in C:\xampp\htdocs\Five9-master\includes\Five9.php on line 20"
$wsdl_five9 = "https://api.five9.com/wsadmin/v4/AdminWebService?wsdl&user=User_ID";
//$wsdl_five9 = "https://api.five9.com/wsadmin/v4/AdminWebService?wsdl";
try {
$soap_options = array('login' => 'uer_name', 'password' => 'mypassword', 'trace' => true);
$this->_connection = new SoapClient($wsdl_five9, $soap_options);//20th line
} catch (Exception $e) {
$error_message = $e->getMessage();
echo $error_message."ERROR";
exit;
}
Please help me to go through this ...
The Above code works fine need to enable soap in your system .
locate your php.ini file and Un-comment(remove semicolon before soap extension)as below.
change from :
";extension=php_soap.dl"
to :
"extension=php_soap.dll" .
I'm having some problems connecting to MS web service hosted at appharbor.com
Here's the php code:
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
try {
$client = new SoapClient("http://ppjparsanje.apphb.com/Prazniki.asmx?wsdl", $options);
print_r($client->__call("get_praznike", array("json")));
print_r($client->get_praznike("json"));
print_r($client->__soapCall("get_praznike", array("json"), array('soapaction' => 'http://ppjparsanje.apphb.com/get_praznike')));
} catch(Excteption $e) {
echo $e->getMessage()."<br />";
}
The error is:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host
Which is strange because service seems to work fine. I have also tried to add port 14275, but no luck. Any suggestions?
Thanks in advance!
you have made a mistake the soap has version 1 na your are passing 1.2 in options then how will it connect
$soapClient = new SoapClient('http://ppjparsanje.apphb.com/Prazniki.asmx?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE) );
print_r($soapClient);
i get output:- hence due to bad code you are getting error
SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #3 )
well here i have acceses uk mail api
take a look at how i have called a method its bit diffrent
but u will get an idea
php soap client for uk mail webservice api?