I trying to call a web service using SOAP protocol with PHP, but it doesn't work.
The url on documentation is:
URL: http://api.teleport.com.br/wsdl/Teleport
My code:
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$url = "http://api.teleport.com.br/wsdl/Teleport";
try {
$client = new SoapClient($url);
$function = 'ConsultaVeiculos';
$arguments= array('ConsultaVeiculos' => array(
"senha" => "*************"
));
$options = array('location' => $url);
$result = $client->__soapCall($function, $arguments);
print_r($result);
} catch (Exception $e) {
print $result." = ".$e;
}
The error:
= SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find in 'http://api.teleport.com.br/wsdl/Teleport' in PATH: SoapClient->SoapClient('http://api.tele...') #1 [internal function]: FUNCION->testSOAPService() #2 PATH/CodeIgniter.php(359): call_user_func_array(Array, Array) #3 PATH(219): require_once(PATH) #4 {main}
How to correctly do this?
Thanks
Related
Can anyone plz help
I have written a soap server and a client to test and it works in localhost and also in the server but when both are in save place but when I try to connect the localhost to the server it would not work. gives error
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\xampp\htdocs\PN Encryptor\service\client.php:9 Stack trace: #0 D:\xampp\htdocs\PN Encryptor\service\client.php(9): SoapClient->__soapCall('hello', Array) #1 {main} thrown in D:\xampp\htdocs\PN Encryptor\service\client.php on line 9
my code
///server
class EncSoapServer
{
public function hello($id){
return "Hello WOrld";
}
}
$options = ['uri' => 'http://prageethniranjan.epizy.com/service'];
$server = new SoapServer(null, $options);
$server->setClass('EncSoapServer');
$server->handle();
/// Client
$client = new SoapClient(null, array(
'location' => "http://prageethniranjan.epizy.com/service/encript.php",
'uri' => "http://prageethniranjan.epizy.com/service",
'trace' => 1 ));
//echo $return = $client->__soapCall("encrypt",array("4.1","this is a text message","Niranjan",1979,8,true));
try{
$responce = $client->__soapCall("hello",array('id'=>1));
echo $responce;
}
catch(SoapFault $e)
{
$response = $client->__getLastResponse();
echo $response;
$response = str_replace("",'',$response); ///My Invalid Symbol
$response = str_ireplace(array('SOAP-ENV:','SOAP:'),'',$response);
$response = simplexml_load_string($response);
echo $response;
}
i try running on localhost it works
and put both script on server it also works
but could not connect it with server
I want request-response with wsdl in php
But I getting error
"Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized"
WSDL https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsarizi?wsdl
My code in index.php
$istek = new SoapClient('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsarizi?wsdl');
$auth = new stdClass();
$auth->Username = '999999';
$auth->Password = '999999testtest';
$header = new SoapHeader('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsarizi?wsdl', 'AuthHeader', $auth, false);
$istek->__setSoapHeaders($header);
echo "<pre>";
print_r($istek->__getTypes());
echo "</pre>";
echo "<hr /><br /><br /><br />";
$sonuc = $istek->seyahatIzinKontrol(array(
'wsuser' => array(
'kullaniciAdi' => '999999',
'sifre' => '999999testtest')
,
'tcKimlikNo' => '15058023598')
);
if ($sonuc->seyahatIzinKontrol) {
echo 'OK';
}else {
echo 'ERROR';
};
Here is the error I'm getting:
Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized in C:\xampp\htdocs\index.php:72 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://servis....', 'http://uetds.un...', 1, 0) #1 C:\xampp\htdocs\index.php(72): SoapClient->__call('seyahatIzinKont...', Array) #2 {main} thrown in C:\xampp\htdocs\index.php on line 72
What my error?
Hello? Is anybody in there?
I've used this before years ago now I'm back. First time gives me this:
Fatal error: Uncaught Services_Twilio_TinyHttpException in /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/TinyHttp.php:119 Stack trace: #0 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio.php(178): Services_Twilio_TinyHttp->__call('post', Array) #1 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/ListResource.php(92): Base_Services_Twilio->createData('/2010-04-01/Acc...', Array) #2 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/Rest/Calls.php(32): Services_Twilio_ListResource->_create(Array) #3 /home/www/skyphilly6.com/twill/index.php(9): Services_Twilio_Rest_Calls->create('8052629166', '8058130331', 'htttttp://demo.twi...') #4 {main} thrown in /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/TinyHttp.php on line 119
Here's my short code tried many additional lines same result:
<?php
require('./twilio-php/Services/Twilio.php');
$version = "2010-04-01";
$account_sid = 'ACcfc1ba0d12c58180319486144bef540e'; $auth_token = 'washere';
$client = new Services_Twilio($account_sid, $auth_token, $version);
$client->account->calls- >create('8052629166','8058133333','htttttp://demo.twilio.com/welcome/voice/');
?>
Also tried uncommenting this same result:
<?php
require('./twilio-php/Services/Twilio.php');
$version = "2010-04-01";
//$account_sid = 'SK5b9d2d022b971335e17ee50c813ae231'; $auth_token = 'was';
$account_sid = 'ACcfc1ba0d12c58180319486144bef540e'; $auth_token = 'was';
$client = new Services_Twilio($account_sid, $auth_token, $version);
//try {
//$call=
$client->account->calls->create('8052629166','8058133333','htttttp://demo.twilio.com/welcome/voice/');
//,array(
//'Method' => 'GET',
//'FallbackMethod' => 'GET',
//'StatusCallbackMethod' => 'GET',
//'Record' => 'false', ));
//echo 'Started call: ' . $call->sid;
//} catch (Exception $e) { echo 'Error: ' . $e->getMessage(); }
?>
Please point me in the right direction.
Added:
$http = new Services_Twilio_TinyHttp('https://api.twilio.com',
array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
))
);
//$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
$client = new Services_Twilio($account_sid, $auth_token, $version,$http);
Noticed it doesn't matter what I use for my token same error
Can't find the error log:
$client->http->debug = true;
Hello?
i need to use this xml file:
http://www.mubashermisr.com/Mubadelayed/Service1.asmx?WSDL
to connect to GetTopGainers methode
i use this code:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.mubashermisr.com/Mubadelayed/Service1.asmx?WSDL";
$parameters = array("Username"=>"xxxx","Password"=>"xxxx","ID"=>"xxxxx");
$client = new SoapClient($wsdl_path, array('trace' => 1));
try {
$result = $client->GetTopGainers($parameters);
print_r($result);
}
catch (SoapFault $exception) {
echo $exception;
}
?>
But i get the following error:
SoapFault exception: [soap:Server] Server was unable to process request.
---> Object reference not set to an instance of an object. in
C:\wamp\www\soap\soap.php:24 Stack trace: #0
C:\wamp\www\soap\soap.php(24): SoapClient->__call('GetTopGainers', Array)
#1 C:\wamp\www\soap\soap.php(24): SoapClient->GetTopGainers(Array) #2
{main}
Any help will be appreciated.
Thanks
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "URL";
$parameters = array("Username"=>"xxx","Password"=>"xxx","ID"=>"xxx");
$header = new SOAPHeader('Namespace', 'Auth', $parameters);
$client = new SoapClient($wsdl_path);
$client->__setSoapHeaders($header);
try {
$topGainers = $client->GetTopGainers(); // Top Gainers
echo"<pre>";
print_r($topGainers);
echo"</pre>";
}
catch (SoapFault $exception) {
echo $exception;
}
?>
Here is my code:
if($approved) {
$payerId = $_GET['PayerID'];
// Get payment_id from database
$paymentId = mysql_query("Select payment_id from transactions_paypal WHERE hash = '".$_SESSION['paypal_hash']."'");
$paymentId = mysql_fetch_array($paymentId);
$payment = Payment::get($paymentId, $apiContext);
echo "<pre>";
var_dump($payment);
echo "</pre>";
die();
}else {
header('Location: ../paypal/cancelled.php');
}
But I get this errors:
Notice: Array to string conversion in
C:\xampp\htdocs\Tipperen\test\PayPal-PHP-SDK\paypal\rest-api-sdk-php\lib\PayPal\Api\Payment.php
on line 322
or
Fatal error: Uncaught exception
'PayPal\Exception\PayPalConnectionException' with message 'Got Http
response code 404 when accessing
https://api.sandbox.paypal.com/v1/payments/payment/Array.' in
C:\xampp\htdocs\Tipperen\test\PayPal-PHP-SDK\paypal\rest-api-sdk-php\lib\PayPal\Core\PayPalHttpConnection.php:159
Stack trace: #0
C:\xampp\htdocs\Tipperen\test\PayPal-PHP-SDK\paypal\rest-api-sdk-php\lib\PayPal\Transport\PayPalRestCall.php(74):
PayPal\Core\PayPalHttpConnection->execute('') #1
C:\xampp\htdocs\Tipperen\test\PayPal-PHP-SDK\paypal\rest-api-sdk-php\lib\PayPal\Common\PayPalResourceModel.php(103):
PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...',
'GET', '', NULL) #2
C:\xampp\htdocs\Tipperen\test\PayPal-PHP-SDK\paypal\rest-api-sdk-php\lib\PayPal\Api\Payment.php(328):
PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...',
'GET', '', NULL, Object(PayPal\Rest\ApiContext), NULL) #3
C:\xampp\htdocs\Tipperen\test\paypal\pay.php(20):
PayPal\Api\Payment::get(Array, Object(PayPal\Rest\ApiContext)) in
C:\xampp\htdocs\Tipperen\test\PayPal-PHP-SDK\paypal\rest-api-sdk-php\lib\PayPal\Core\PayPalHttpConnection.php
on line 159
Please help me.