把服务器上的soap开启后,重新了下代码 $client = new SoapClient($url); $soap_header = New SoapHeader($url, 'CallbackHandler', 'wsAdmin',FALSE, SOAP_ACTOR_NEXT); $client->__setSoapHeaders(array($soap_header)); $info = $client->__soapCall('getClassStudent', array('userId' => 1));print_r($info);
运行后,每次都报错 SoapFault exception: [ns1:InvalidSecurity] An error was discovered processing the header in /var/www/html/Exam/Lib/Action/Home/IndexAction.class.php:264 Stack trace: #0
今天终于弄好了,我想以后应该也会有人有此疑惑的,顾贴出源码,省去我这几天所浪费的时间 $xml = ' <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>admin</wsse:Username> <wsse:Password>PasswordText</wsse:Password> </wsse:UsernameToken> </wsse:Security>';$s = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'CallbackHandler', new SoapVar($xml, XSD_ANYXML), TRUE);$client = new SoapClient($wsdl); $client->__setSoapHeaders(array($s)); print_r($client);
$client = new SoapClient($url);
$soap_header = New SoapHeader($url, 'CallbackHandler', 'wsAdmin',FALSE, SOAP_ACTOR_NEXT);
$client->__setSoapHeaders(array($soap_header));
$info = $client->__soapCall('getClassStudent', array('userId' => 1));print_r($info);
运行后,每次都报错
SoapFault exception: [ns1:InvalidSecurity] An error was discovered processing the header in /var/www/html/Exam/Lib/Action/Home/IndexAction.class.php:264 Stack trace: #0
$xml = '
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>admin</wsse:Username>
<wsse:Password>PasswordText</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>';$s = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'CallbackHandler', new SoapVar($xml, XSD_ANYXML), TRUE);$client = new SoapClient($wsdl);
$client->__setSoapHeaders(array($s));
print_r($client);