Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中从soap头访问凭据信息_Php_Soap - Fatal编程技术网

在PHP中从soap头访问凭据信息

在PHP中从soap头访问凭据信息,php,soap,Php,Soap,我需要从php脚本中的soap头访问用户名和密码。我可以访问正文信息,但无法访问标题信息。 这是肥皂 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://schemas.xmlsoap.org/ws/2002/04/secext" xmlns:met="http://www.example.com/data"> <soap

我需要从php脚本中的soap头访问用户名和密码。我可以访问正文信息,但无法访问标题信息。 这是肥皂

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"        xmlns:sec="http://schemas.xmlsoap.org/ws/2002/04/secext" 
xmlns:met="http://www.example.com/data">
   <soapenv:Header>
      <sec:Security>
         <UsernameToken>
            <Username>ron</Username>            
            <Password>pass</Password>
         </UsernameToken>
      </sec:Security>
   </soapenv:Header>
   <soapenv:Body>
      <met:columnInfo>
         <databaseName>MySQL</adaptorName>        
         <tableName>product</tableName>
      </met:columnInfo>
   </soapenv:Body>
</soapenv:Envelope>

罗恩
通过
MySQL
产品

非常感谢您的帮助。

Ok找到了解决方案

$server = new SoapServer($anywsdl);
$server->addFunction(addAllFuntions);
$server->handle();
然后在同一个php脚本中

function Security($data){   
$UserToken=get_object_vars($data);
foreach($UserToken as $uToken){
    $credentialArray=get_object_vars($uToken);
    echo $credentialArray['Username'];
    echo $credentialArray['Password'];      
}

}
如果Security()函数位于不同的类中,则需要$server->setClass($yourClass)