can't access a web server using soap and wsdl - php

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.

Related

Uncaught SoapFault exception: [HTTP] Forbidden

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?

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

Issue with PHP Script to reboot Rackspace server

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.

PHP SOAP : Object reference not set to an instance of an object

I need your help
I have to use PHP functions from a web service SOAP
The request XML is as follows
<OTA_HotelDescriptiveInfoRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="1">
<POS>
<Source AgentSine="user" AgentDutyCode="pass" />
</POS>
<HotelDescriptiveInfos>
<HotelDescriptiveInfo ChainCode="H4U" HotelCode="696"/>
</HotelDescriptiveInfos>
</OTA_HotelDescriptiveInfoRQ>
Here is my PHP code:
$soapClient = new SoapClient("http://otatest.apixml.com/dispatcher.asmx?WSDL");
$header = new SOAPHeader('http://xmlota.wspan.com/webservice/', 'authentication', array('username' => 'user', 'password' => 'pass'));
$soapClient->__setSoapHeaders($header);
$param['POS']['Source']['AgentSine'] = 'user';
$param['POS']['Source']['AgentDutyCode'] = 'pass';
$param['HotelDescriptiveInfos']['HotelDescriptiveInfo']['ChainCode'] = 'H4U';
$param['HotelDescriptiveInfos']['HotelDescriptiveInfo']['HotelCode'] = '696';
$response = $soapClient->sendOTAHotelDescriptiveInfo($param);
And here is the error I'm trying for several days but I can not resolve it
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request.
---> System.NullReferenceException: Object reference not set to an instance of an object. at H4U.Webservices.OTA.SoapDispatcher.sendOTAHotelDescriptiveInfo(OTA_HotelDescriptiveInfoRQ OTA_HotelDescriptiveInfoRQ)
--- End of inner exception stack trace ---
in /home/dimavoya/public_html/soap/soap.php:43
Stack trace:
#0 /home/dimavoya/public_html/soap/soap.php(43): SoapClient->__call('sendOTAHotelDes...', Array)
#1 /home/dimavoya/public_html/soap/soap.php(43): SoapClient->sendOTAHotelDescriptiveInfo(Object(SoapVar))
#2 {main} thrown in
I remain at your disposal for more information
Thank you in advance

Categories