2018-08-25 19:20
浏览 124


I am trying to create SOAP request, but it gives me error: An exception occurred whilst trying to authenticate you. String reference not set to an instance of a String. Parameter name: s My code is:

$wsdl   = ""; 
$trace = true;
$exceptions = false;
$debug = true;

$client = new SoapClient($wsdl,
        'trace' => $trace,
        'exceptions' => $exceptions,
        'debug' => $debug,

    $xml = '<soapenv:Envelope xmlns:soapenv="" xmlns:kas="KashFlow">

    $args = array(new SoapVar($xml, XSD_ANYXML)); 
    $res  = $client->__soapCall('GetInvoice', $args);
echo "<hr>Last Request";
echo "<pre>", htmlspecialchars($client->__getLastRequest()), "</pre>";

Does anyone know how to solve? The request works fine if I use:

$wsdl = '';
$trace = true;
$exceptions = false;
$debug = true;

$client = new SoapClient($wsdl,
        'trace' => $trace,
        'exceptions' => $exceptions,
        'debug' => $debug,

$params = array(
   'InvoiceNumber' =>'81217',
    'UserName' => 'xxx', 
    'Password' => 'xxx'

$resp = $client->GetInvoice($params);


This is request with simple parameters, but in real situation I have complex XML request, that I do not know how to form as php object. That is why I would send it as XML as I am trying to do at first place.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dougu5950 2018-08-27 12:03

    Nowadays, it is strongly advised to use a WSDL to PHP generator in order to avoid encountering this sort of issues.

    I recomend using the PackageGenerator project which allows to generate a PHP SDK based on the WSDL. The generated PHP SDK contains all that is necessary to construct the request, send the request and handle the response only using an OOP approach.

    打赏 评论

相关推荐 更多相似问题