Uncaught SoapFault exception: [HTTP] Forbidden - php

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?

Related

Uncaught SoapFault exception: [soap:Server] Server was unable to process request

i use this PHP Code :
<?php
ini_set("soap.wsdl_cache_enabled", "0");
$AccountShabaCode = "123456789012345678900000";
$WorkTitle = "Example";
$GuildCode = "48160000";
$PardakhtYarTitle = "Xxxa";
$soapclient = new SoapClient('http://87.107.134.111:8021/PardakhtYar.asmx?wsdl');
$add_new_request = $soapclient->AddNewRequest(array('AccountShabaCode' => $AccountShabaCode, 'Password' => $Password, 'WorkTitle' => $WorkTitle, 'GuildCode' => $GuildCode, 'PardakhtYarTitle' => $PardakhtYarTitle));
print_r($add_new_request);
?>
and get this error :
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\WAMP\home\example.tld\public_html\test.php:11
Stack trace:
#0 C:\WAMP\home\example.tld\public_html\test.php(11): SoapClient->__call('AddNewRequest', Array)
#1 {main}
thrown in C:\WAMP\home\example.tld\public_html\test.php on line 11
How can I fix this error?
i need call "AddNewRequest" ( http://87.107.134.111:8021/PardakhtYar.asmx?op=AddNewRequest )

How to login Five9 through API

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" .

How to set up SOAP client and server using php

i have some problems with the soap client and soap server.
server.php on server side
class Server {
public function hello($someone) {
return "Hello ". $someone;
}
}
$options= array('uri'=>'http://localhost/');
$server=new SoapServer(NULL, $options);
$server->setClass('Server');
$server->handle();
index.php on client side
<?php
$options = array('location' => 'http://localhost/server.php',
'uri' =>'http://localhost/');
$client = new SoapClient(NULL, $options);
echo $client->hello('Greg');
I'm testing this local on xampp and get the Error:
What do i make wrong ? Can i test it localy or do i have to set up a server for this. If yes, is it possible to run this on IIS ?
Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in
C:\xampp\htdocs\SOAP\index.php:8 Stack trace: #0 [internal function]:
SoapClient->__doRequest('http://localhos...',
'http://localhos...', 1, 0) #1 C:\xampp\htdocs\SOAP\index.php(8):
SoapClient->__call('hello', Array) #2
C:\xampp\htdocs\SOAP\index.php(8): SoapClient->hello('Greg') #3 {main}
thrown in C:\xampp\htdocs\SOAP\index.php on line 8

php code not working for SOAP API, TNT

I am working on TNT SOAP based API, I am using below code but gets only error, I can`t understand what I am doing wrong ?
ini_set("default_socket_timeout",120);
$client = new SoapClient('https://uat.tntexpress.com.au/Webservices/Conservice/ConsignmentService.svc?wsdl');
$params = array(
'payingAccount' => '20003191',
'UserName' => 'NEX-APIT',
'Password' => 'NEX_APIPWT'
);
$response = $client->__soapCall('ProcessConsignmentRequest',$params);
print_r($response);
I am getting this error :
Fatal error: Uncaught SoapFault exception: [s:Client] The creator of this fault did not specify a Reason. in D:\xampp\htdocs\tnt\soap.php:11
Stack trace:
#0 D:\xampp\htdocs\tnt\soap.php(11): SoapClient->__soapCall('ProcessConsignm...', Array)
#1 {main} thrown in D:\xampp\htdocs\tnt\soap.php on line 11
I found here the working code tnt-express

can't access a web server using soap and wsdl

I wrote the following code:
<?php
$url = "https://ops.isignmedia.com/iSign-ear-iSign-ejb/DownloadServices4?wsdl";
$client = new SoapClient($url);
$fcs = $client->__getFunctions();
var_dump($fcs);
$res = $client->downloadData(array('startDateTime' => 'null', 'endDateTime' => 'null','accountCode' => 'xxxx', 'userName' => 'xxxx', 'password' => 'xxxx'));
print_r($res);
?>
The error that I get is the following:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/gsapte/public_html/grupsapte/test_webservice/isign.php:10 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://ip-172-3...', '', 1, 0) #1 /home/gsapte/public_html/grupsapte/test_webservice/isign.php(10): SoapClient->__call('downloadData', Array) #2 /home/gsapte/public_html/grupsapte/test_webservice/isign.php(10): SoapClient->downloadData(Array) #3 {main} thrown in /home/gsapte/public_html/grupsapte/test_webservice/isign.php on line 10
If I punt another wsdl address then using this method I can access all information I need. Question: what can be the reasons that I can't access that wsdl? can it be that is https instead of http?
If you open this WSDL then on the bottom you will see:
<port binding="tns:DownloadWebServices4Binding" name="DownloadWebServices4Port">
<soap:address location="http://ip-172-31-46-241.us-west-2.compute.internal:8080/iSign-ear-iSign-ejb/DownloadServices4"/>
</port>
This host might not be available. This is also visible in error message.
If you know other endpoint to this service try to use location or uri parameter to SoapClient.

Categories