我遇到了一些SOAP问题。我的系统中有一些功能,可以检查人是否是债务人。它工作了很长时间,但突然停了下来。 现在,当我尝试调用此函数时,我收到此错误:
Error 500
com.sun.xml.wss.impl.WssSoapFaultException: Authentication of Username Password Token Failed; nested exception is com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.impl.WssSoapFaultException: Authentication of Username Password Token Failed
这是我的控制者:
public function actionQuery($client, $loan)
{
$client = Client::model()->findByPk($client);
$loan = Loan::model()->findByPk($loan);
list($success, $exists, $debtorsInfoPersonId) = $client->getDebtorInfo($loan->add);
if ($success) {
Report::set(Report::SUCCESS, Yii::t('app', 'Data received'));
}
if ($exists) {
Report::set(Report::NOTICE, Yii::t('app', 'Debtor exists'));
} else {
Report::set(Report::NOTICE, Yii::t('app', 'Debtor not exists'));
}
$url = Yii::app()->request->getParam('returnUrl', null);
$this->redirect($url != null ? base64_decode($url) : ['view', 'id' => $model->debtorPerson->getPrimaryKey()]);
}
这是肥皂的组成部分。
private function generateWSSecurity($user, $password)
{
// Creating date using yyyy-mm-ddThh:mm:ssZ format
$tm_created = gmdate('Y-m-d\TH:i:s\Z');
$tm_expires = gmdate('Y-m-d\TH:i:s\Z', gmdate('U') + 180);
// Generating, packing and encoding a random number
$simple_nonce = mt_rand();
$encoded_nonce = base64_encode(pack('H*', $simple_nonce));
// Compiling WSS string
$passdigest = base64_encode(pack('H*',
sha1(pack('H*', $simple_nonce) . pack('a*', $tm_created) . pack('a*', $password))));
// Initializing namespaces
$ns_wsse = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
$ns_wsu = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
$password_type = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest';
//$password_type = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0.pdf';
$encoding_type = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary';
//$encoding_type = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0.pdf';
// Creating WSS identification header using SimpleXML
$root = new \SimpleXMLElement('<root/>');
$security = $root->addChild('wsse:Security', null, $ns_wsse);
$timestamp = $security->addChild('wsu:Timestamp', null, $ns_wsu);
$timestamp->addAttribute('wsu:Id', 'Timestamp-28');
$timestamp->addChild('wsu:Created', $tm_created, $ns_wsu);
$timestamp->addChild('wsu:Expires', $tm_expires, $ns_wsu);
$usernameToken = $security->addChild('wsse:UsernameToken', null, $ns_wsse);
$usernameToken->addChild('wsse:Username', $user, $ns_wsse);
$password = $usernameToken->addChild('wsse:Password', $passdigest, $ns_wsse);
$password->addAttribute('Type', $password_type);
$nonce = $usernameToken->addChild('wsse:Nonce', $encoded_nonce, $ns_wsse);
$nonce->addAttribute('EncodingType', $encoding_type);
$usernameToken->addChild('wsu:Created', $tm_created, $ns_wsu);
// Recovering XML value from that object
$root->registerXPathNamespace('wsse', $ns_wsse);
$full = $root->xpath('/root/wsse:Security');
$auth = $full[0]->asXML();
return $auth;
}
当我使用die("error")
检查问题出在哪里时,一切正常,直到return $auth;
。此返回后显示错误。有什么线索我做错了什么?