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
Related
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 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
I never developed a SOAP client, and now I have to do it and am having difficulties. This are the input parameters I have to send to the method "Agregar":
<Clientes>
<Cliente>
<Rut>123456785</Rut>
<Nombre>123456785</Nombre>
</Cliente>
</Clientes>
this is the testing code for the client I have done yet:
<?php
class Socio {
function Socio($rut, $nombre)
{
$this->nombre = $nombre;
$this->rut = $rut;
}
}
$client = new SoapClient("theurl...");
$socio = new Socio(156371777, "Sebastian");
$params = array(
"Cliente" => $socio,
);
$response = $client->__soapCall("Agregar", $params);
var_dump($response);
but it is not working... I get the following error:
Fatal error: Uncaught SoapFault exception: [soap:Server] The server can't process the request. ---> The value cannot be null. Parameter name: s in /var/www/friends/awto/intouch/ccinterface.php:22 Stack trace: #0 /var/www/friends/awto/intouch/ccinterface.php(22): SoapClient->__soapCall('Agregar', Array) #1 {main} thrown in /var/www/friends/awto/intouch/ccinterface.php on line 22
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.
I have been struggling to write a PHP script that will reboot a server using the 1.6.0 version of the Rackspace API (I can't install Composer on my server needed for 1.7.0). Unfortunately it does not want to recognize my credentials and keeps throwing this error:
Fatal error: Uncaught exception 'OpenCloud\Common\Exceptions\CredentialError' with message 'Unrecognized credential secret' in /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php:694 Stack trace: #0 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/Rackspace.php(66): OpenCloud\OpenStack->credentials() #1 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php(714): OpenCloud\Rackspace->Credentials() #2 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php(591): OpenCloud\OpenStack->authenticate() #3 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php(652): OpenCloud\OpenStack->checkExpiration() #4 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/Common/Service.php(337): OpenCloud\OpenStack->serviceCatalog() #5 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/Common/Service.php(68): OpenCloud\Common\Service->getEndpoint('compute', 'cloudServersOpe...', 'ORD', 'publicURL') #6 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/ in /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php on line 694
Here is my PHP script (I did not include my credentials)
require_once "php-opencloud.php";
// The AUTHURL used for the US was: https://identity.api.rackspacecloud.com/v2.0/
putenv("RAX_USERNAME=$username");
putenv("RAX_API_KEY=$apikey");
putenv("RAX_TENANT_NAME=$tenantname");
putenv("RAX_AUTH_URL=$authurl");
define('USERNAME', $_ENV['RAX_USERNAME']);
define('APIKEY', $_ENV['RAX_API_KEY']);
define('TENANT', $_ENV['RAX_TENANT_NAME']);
define('AUTHURL', 'RAX_AUTH_URL');
$rackspace = new \OpenCloud\Rackspace(AUTHURL,
array( 'username' => USERNAME,
'apiKey' => APIKEY ));
$cservers = $rackspace->Compute('cloudServersOpenStack', 'ORD');
$list = $cservers->ServerList();
while($server = $list->Next()) {
if ($server->name == 'My_Server')
$server->Reboot('hard');
}
echo "Reboot sequence complete.";
Any help anyone can offer would be greatly appreciated.