PHP Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized in - php

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?

Related

soap not connecting in server PHP

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("&#x1A",'',$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

Calling web service not working

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

MongoDB Remote Connections

I installed MongoDB the last version
and i want to connect to MongoDB with an other server with this test code.
- installed MongoDB Driver in PHP Server
- Allowed PHP Server IP in MongoDB iptabels:
PHP Code:
<?php
$m = new MongoClient("mongodb://X.X.X.X:27017");
$dbname = $m->selectDB("Test");
$collection = $dbname->selectCollection("Shows");
$data1 = array(
'user_id' => 'salam',
'age' => 20,
'Status' => 'Allll'
);
$dbname = $collection->insert($data1, array('$data1' => 1));
$results = $collection->find();
echo "<pre>";
foreach($results as $test) {
print_r($test);
}
echo "</pre>";
?>
ERROR:
atal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: X.X.X.X.X.X:27017: Connection timed out' in /home/payam48/domains/.../public_html/includes/classes/class.mongodatabase.php:9 Stack trace: #0 /home/payam48/domains/.../public_html/includes/classes/class.mongodatabase.php(9): MongoClient->__construct('mongodb://178.1...') #1 /home/payam48/domains/.../public_html/includes/classes/class.doctor.php(519): Mongodatabase->__construct('1c5b98782e44ccd...', 'b2f202952b685b6...') #2 /home/payam48/domains/.../public_html/includes/classes/class.doctor.php(486): Doctor->online_delete() #3 /home/payam48/domains/.../public_html/application/controllers/managedoctor.php(27): Doctor->delete('4') #4 /home/payam48/domains/.../public_html/application/core/router.class.php(118): managedoctorController->delete() #5 /home/payam48/domains/.../public_html/index.php(9): router-> in /home/payam48/domains/.../public_html/includes/classes/class.mongodatabase.php on line 9

Get Sharepoint data list in php

I tried to get SharePoint list in php. Below is code
require_once __DIR__ . '\Faker-master\src\autoload.php'; //Faker library (https://github.com/fzaninotto/Faker)
require_once 'lib/SPOClient.php';
$username = 'aaaa.aaa#microsoft.com';
$password = '*******';
$url = "https://microsoft.sharepoint.com";
generateContacts($url,$username,$password);
function generateContacts($url,$username,$password){
$client = new SPOClient($url);
$client->signIn($username,$password);
$list = $client->getList('ClientMaster');
$contactsCount = 120;
for($i = 0; $i < $contactsCount; $i++){
$contactEntry = createContactEntry();
$item = $list->addItem($contactEntry);
print "Contact '{$item->Title}' has been created succesfully.\r\n";
}
}
O/p:
Fatal error: Uncaught exception 'Exception' with message 'Invalid STS request. ' in E:\Apps\xampp\htdocs\ep\lib\SPOClient.php:260 Stack trace: #0 E:\Apps\xampp\htdocs\ep\lib\SPOClient.php(242): SPOClient->processToken('requestToken('ssss.kkkk...', '*****') #2 E:\Apps\xampp\htdocs\ep\listexamples.php(24): SPOClient->signIn('ssss.kkkk...', '******') #3 E:\Apps\xampp\htdocs\ep\listexamples.php(15): generateContacts('https://worldem...', 'sssss.kkk...', '******') #4 {main} thrown in E:\Apps\xampp\htdocs\ep\lib\SPOClient.php on line 260

Paypal SDK problen

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.

Categories