KPSv2 kimlik bilgileri sorgulamak istiyorum.
Örnek uygulamaları mevcut fakat php dilinde bulunmuyor. Kendim bir fonksiyon yazdım ama STS servis cevabı alamıyorum. Bana yardımcı olabilir misiniz?

CSharpConsole Örnek Uygulama
https://kpsv2.saglik.gov.tr/assets/samples/KPS_CSharpConsoleApp_SoapRequest.zip


Benim Yazdığım Örnek Kod;

index.php

/**
* Created by PhpStorm.
* User: aykutokyay
* Date: 18.05.2019
* Time: 00:44
*/

ini_set('memory_limit','512M');
error_reporting(E_ALL);
ini_set("display_errors", 1);

require 'KPSRequestSample.php';


$kullanici = 'test_user';
$sifre = 'f6)@6U:l';

$kps = new KPSRequestSample();
$sorgu = $kps->GetSTSToken($kullanici, $sifre);

print_r($sorgu);


KPSRequestSample.php

/**
* Created by PhpStorm.
* User: aykutokyay
* Date: 18.05.2019
* Time: 00:45
*/

class KPSRequestSample
{

//Gerçek Ortam
const kpsUrl = "https://kpsv2.saglik.gov.tr/Router/RoutingService.svc";
const stsUrl = "https://kpsv2.saglik.gov.tr/STS/STSService.svc";

//Test Ortamı
const kpsTestUrl = "https://kpsv2test.saglik.gov.tr/Router/RoutingService.svc";
const stsTestUrl = "https://kpsv2test.saglik.gov.tr/STS/STSService.svc";


public function BilesikKisiSorgula($kimlikNo, $username, $password){

$kpsTestUrl = static::kpsTestUrl;
$stsTestUrl = static::stsTestUrl;

$NewGuid = $this->uuid();
$token = $this->GetSTSToken($username,$password);
$created = $this->getZamanDamgasi();
$expires = $this->getZamanDamgasi(300);

$kpsRequestEnvelope = <<

https://www.saglik.gov.tr/KPS/01/01/2017/IKpsServices/BilesikKisiSorgula
urn:uuid:$NewGuid

http://www.w3.org/2005/08/addressing/anonymous

$kpsTestUrl


$created
$expires

$token




$kimlikNo



XML;

$result = $this->SendSoapRequest($kpsTestUrl, $kpsRequestEnvelope);

return $result;

}

public function GetSTSToken($username,$password){

//Test Ortamı
$kurumKodu = 123456;
$uygulamaKodu = "8353df93-453c-4e23-8be8-2f913dd35313";

$created = $this->getZamanDamgasi();
$expires = $this->getZamanDamgasi(300);

$NewGuid = $this->uuid();

$kpsTestUrl = static::kpsTestUrl;
$stsTestUrl = static::stsTestUrl;

$sorgu = <<

http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue
urn:uuid:$NewGuid

http://www.w3.org/2005/08/addressing/anonymous

$stsTestUrl
$kurumKodu
$uygulamaKodu


$created
$expires
");

$username
$password







$kpsTestUrl


http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer
http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue



EOD;

$tokenSend = $this->SendSoapRequest($stsTestUrl, $sorgu);

return $tokenSend;
}

public function SendSoapRequest($adres, $xml){
date_default_timezone_set('Asia/Istanbul');


$headers = array(
'Content-type: application/soap+xml; charset=utf-8',
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache',
'SOAPAction: '.$adres,
'Content-Length: '.strlen($xml),
);

$options = array(
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => 1, // return web page
CURLOPT_HEADER => 1, // don't return headers
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $xml,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_VERBOSE => 1,
CURLOPT_TIMEOUT => 10,
);

$soap_do = curl_init($adres);
curl_setopt_array($soap_do, $options);
/*
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers);
curl_setopt($soap_do, CURLOPT_VERBOSE, 1);
*/

if(curl_exec($soap_do) === false) {
$err = 'Curl error: ' . curl_error($soap_do);
curl_close($soap_do);
print $err;
} else {
$response = curl_exec($soap_do);
/*
$header_size = curl_getinfo($soap_do, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
*/
curl_close($soap_do);
return $response;
}

/*
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $adres);
curl_setopt($ch, CURLOPT_REFERER, "https://kpsv2test.saglik.gov.tr/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/soap+xml; charset=utf-8',
));
$sonuc = curl_exec($ch);
curl_close($ch);
return $sonuc;
}catch (Exception $e) {
return $e;
}
*/

}

private function getZamanDamgasi($aralik = 0) {
return gmdate("Y-m-d\TH:i:s\Z", time() + $aralik);
}

/**
* Generates UUID
*
* @return string UUID
*/
protected function uuid()
{
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', //
mt_rand(0, 0xffff), //
mt_rand(0, 0xffff), //
mt_rand(0, 0xffff), //
mt_rand(0, 0x0fff) | 0x4000, //
mt_rand(0, 0x3fff) | 0x8000, //
mt_rand(0, 0xffff), //
mt_rand(0, 0xffff), //
mt_rand(0, 0xffff) //
);
}
}