通过.pem加载时缺少PHP SOAP客户端安全标头

时间:2016-11-15 09:22:52

标签: php soap http-headers soap-client nusoap

虽然我试图通过肥皂发送标题我在这里得到以下错误是我的代码和错误消息,请检查

错误讯息 致命错误:SOAP Fault :( faultcode:wsse:InvalidSecurity,faultstring:在请求中缺少wsse:Security头)

//require_once("lib/nusoap.php");
    $private_key=file_get_contents('client.pem');
    $private=der2pem($private_key); 
    $local_cert = (string)$private;
    $ws = 'url/wsdl';  //wsdl file   
    //define the soap server location  
    $vLocation = "xxxx"; 
    $client = new SoapClient($ws, array(  
    "location" => $vLocation,  
    "trace"=>1, 
    "exceptions"=>1,       
    "local_cert" => $local_cert
    ));  
    $username = 'username';
    $password = 'password';
    $headerbody = array('username ' => $username, 
    'password ' => $password); 
    $ns = 'xxxx'; //Namespace of the web service.                                       
    $header = new SOAPHeader($ns,'requestHeader', $headerbody,true);
    $client->__setSoapHeaders($header);
    $params=array('name'=>'myname');  
    try{
    print_r($client);
    $op=$client->authHelloWS($params); 
    }
    catch (SoapFault $fault) {
    trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
    }
    function der2pem($der_data, $type='CERTIFICATE') {
    $pem = chunk_split(base64_encode($der_data), 64, "\n");
    $pem = $type.$pem.$type;
    return $pem;
    } 

0 个答案:

没有答案
相关问题