public function getMerchantInfo($hzParam)
если убрать аргумент $hzParam, естественно подправим phpDoc, сервис выдает ошибку
Код: Выделить всё
SoapFault Object
(
[message:protected] => Error cannot find parameter
Сервер
Код: Выделить всё
<?php
class SoapController extends Api
{
public function actions()
{
return array(
'wsdl'=>array(
'class'=>'CWebServiceAction',
// Use classMap for complex data types
'classMap'=>array(
),
),
);
}
/**
* @param null $auth
* @throws SoapFault
*/
public function authHeader($auth = null)
{
$this->merchantId = intval($auth->merchantId);
$this->secretHash = $auth->secretHash;
$this->merchantInfo = Merchant::model()->getMerchantById($this->merchantId);
if($auth->secretHash != $this->cryptSecretKey('XXXXXXXX')){
throw new SoapFault("Server", "Incorrect key");
}
}
/**
* @param array
* @return array
* @soap
*/
public function getMerchantInfo($hzParam)
{
return $this->filterMerchantInfo();
}
}
Код: Выделить всё
try {
$client=new SoapClient($this->wsdl, array('cache_wsdl' => 0, 'exceptions' => 0,
'trace' => 0
));
// Create the header
$auth = new auth($this->merchantId, hash('sha256', md5($this->secret)));
$header = new SoapHeader($this->wsdl, 'authHeader', $auth, false);
$client->__setSoapHeaders($header);
$soapRes = $client->__soapCall("getMerchantInfo", array('encoding'=>'utf-8'));
if (! $soapRes)
throw new Exception("Could not open service!");
}
catch (Exception $e) {
$soapRes = "Error (File: ".$e->getFile().", line ".
$e->getLine()."): ".$e->getMessage();
}
Код: Выделить всё
class auth
{
public $secretHash;
public $merchantId;
public function __construct($merchantId, $hash)
{
$this->secretHash = $hash;
$this->merchantId = $merchantId;
}
}