2018-10-16 07:18
浏览 187

用于身份验证问题的PHP SOAP标头

I have the below SOAP XML, Im trying to access the vehicle details with the soap header authentication. I have tried the below code. I think, Im missing something on this. Can u help

SOAPAction: ""

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
    <UserIdentifierSoapHeaderIn xmlns="">
    <getVehicleDetails xmlns="">

PHP code along with the SOAP Header, I have created as the below.

$wsdl   = "";
$client = new SoapClient($wsdl, array('trace'=>1));  // The trace param will show you errors stack

 $auth = array(
$header = new SOAPHeader($wsdl, 'UserIdentifierSoapHeaderIn', $auth);        

// web service input params
$request_param = array(
    "SystemCode" => 4,
    "UserID" => "TEST",
    "ChassisNo" => '1N4AL3A9XHC214925'

$responce_param = null;
    $responce_param = $client->getVehicleDetails($request_param);
   //$responce_param =  $client->call("webservice_methode_name", $request_param); // Alternative way to call soap method
catch (Exception $e) 
    echo "<h2>Exception Error!</h2>"; 
    echo $e->getMessage(); 



Can u guide if anything I have written wrong here in this.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • doubaoxue5788 2018-10-16 07:28

    You can use the __soapCall method like this:

    $result = $client->__soapCall('webserviceMethodeName', ['parameters' => $params]);

    In your case a soap action would be invoked like this:

    $responce_param = $client->__soapCall('getVehicleDetails', ['parameters' => $request_param]);

    Read more

    解决 无用
    打赏 举报

相关推荐 更多相似问题