Я пытаюсь получить данные из веб-сервиса SOAP, но он не может подключиться к хосту. Я попробовал множество решений в своем коде следующим образом:
require 'soap-wsse.php';
define('PRIVATE_KEY', 'technologyally.me.key.pem');
define('CERT_FILE', 'technologyally.me.crt');
class MySoap extends SoapClient
{
private $_username;
private $_password;
private $_digest;
public function addUserToken($username, $password, $digest = false)
{
$this->_username = $username;
$this->_password = $password;
$this->_digest = $digest;
}
public function __doRequest($request, $location, $saction, $version, $one_way =
0)
{
$doc = new DOMDocument('1.0');
$doc->loadXML($request);
$objWSSE = new WSSESoap($doc);
/* Sign all headers to include signing the WS-Addressing headers */
$objWSSE->signAllHeaders = true;
$objWSSE->addTimestamp();
$objWSSE->addUserToken($this->_username, $this->_password, $this->_digest);
/* create new XMLSec Key using RSA SHA-1 and type is private key */
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
/* load the private key from file - last arg is bool if key in file (true) or is string (FALSE) */
$objKey->loadKey(PRIVATE_KEY, true);
/* Sign the message - also signs appropraite WS-Security items */
$objWSSE->signSoapDoc($objKey);
/* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
$token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
$objWSSE->attachTokentoSig($token);
$request = $objWSSE->saveXML();
//print_r($request);
//echo $location;
// $location='https://impl.hub.cms.gov/Imp1/ApplicantEligibilityService';
return parent::__doRequest($request, $location, $saction, $version);
}
}
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$wsdl = 'WSDL/ApplicantEligibility.wsdl';
$context = stream_context_create(array('ssl' => array(
"verify_peer"=>false,
// ,"allow_self_signed"=>false,
//'cafile' => 'cacert.pem',
// 'verify_depth' => 5,
// 'local_pk'=>PRIVATE_KEY,
// 'allow_self_signed' => false,
'ciphers' => 'DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA:KRB5-DES-CBC3-MD5:KRB5-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:AES128-SHA:RC2-CBC-MD5:KRB5-RC4-MD5:KRB5-RC4-SHA:RC4-SHA:RC4-MD5:RC4-MD5:KRB5-DES-CBC-MD5:KRB5-DES-CBC-SHA:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:DES-CBC-MD5:EXP-KRB5-RC2-CBC-MD5:EXP-KRB5-DES-CBC-MD5:EXP-KRB5-RC2-CBC-SHA:EXP-KRB5-DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC2-CBC-MD5:EXP-KRB5-RC4-MD5:EXP-KRB5-RC4-SHA:EXP-RC4-MD5:EXP-RC4-MD5',
)));
$sClient = new MySoap($wsdl, array(
// 'location' => 'https://impl.hub.cms.gov/Imp1/ApplicantEligibilityService',
// 'style' => SOAP_DOCUMENT,
'trace' => 1,
'soap_version' => SOAP_1_2,
'exceptions' => true,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
'cache_wsdl' => WSDL_CACHE_NONE,
// 'ssl_method' => SOAP_SSL_METHOD_TLS,
'stream_context' => $context,
"style" => SOAP_DOCUMENT,
"use" => SOAP_LITERAL,
'connection_timeout'=>60
));
//$sClient = new MySoap($wsdl, array('stream_context' => $context));
//echo file_get_contents('https://impl.hub.cms.gov/Imp1/HubConnectivityService');exit();
$sClient->__setLocation('https://impl.hub.cms.gov/Imp1/ApplicantEligibilityService');
$sClient->addUserToken('04.BKS.KS*.913.430', 'Qzk@4iTjUodAn2R', true);
//print_R($sClient->__getFunctions());
$parameter['PartnerWebSiteInformationExchangeSystem']['InformationExchangeSystemIdentification']['IdentificationID'] =
'04.DSH.TS*.001.001';
$parameter['ExchangeInformationExchangeSystem']['InformationExchangeSystemStateCode'] =
'GA';
$parameter['ExchangeInformationExchangeSystem']['InformationExchangeSystemIdentification']['IdentificationID'] =
'04.DSH.TS*.001.001';
$parameter['PartnerAssignedConsumerIdentification']['IdentificationID'] =
'ConsumerScenario';
$parameter['PartnerWebSiteUserCode'] = 'Consumer';
$parameter['ExchangeAssignedConsumerIdentification']['IdentificationID'] =
'124838339';
$parameter['ExchangeUser']['ExchangeUserIdentification']['IdentificationID'] =
'[email protected]';
$parameter['ExchangeUser']['RoleOfPersonReference'] = '';
//print_R($parameter);
try
{
$out = $sClient->FetchApplicantEligibility($parameter);
var_dump($out);
}
catch (SoapFault $fault)
{
//echo $sClient->__getLastRequest();
print_R($fault);
}
Я получил ответ от этого на SOAPUI успешно, который использует хранилище ключей и заголовок ws-security, Где-то я делаю что-то не так, можете ли вы указать мне правильное направление, заранее спасибо, я застрял в этом с тех пор навсегда 🙁
Задача ещё не решена.
Других решений пока нет …