【发布时间】:2014-07-04 12:47:49
【问题描述】:
我正在尝试使用 SOAP / wsdl 连接到 Web 服务并对其进行身份验证,但我不断收到错误消息:
<b>Fatal error</b>: Uncaught SoapFault exception: [a:InternalServiceFault] Object reference not set to an instance of an object. in /path/install.php:16
以下是我当前的代码:
<?php
header("Content-Type: text/plain");
$userinfo = array(
'Username'=>'test',
'Password'=>'test'
);
$wsdl_url = 'https://ws-e-distribution.kmd.dk/standard/ServiceAutorisation/ServiceAutorisation.svc?wsdl';
$client = new SoapClient($wsdl_url);
print_r($client->__getFunctions());
print_r($client->__getTypes());
//This is the problematic line:
$response = $client->__soapCall('LogOn', array('LogOn' => $userinfo));
var_dump($response);
我已经尝试了所有可能的包装用户名和密码参数的方法,我可以想到或找到任何人建议:
- 使用自定义类
- 使用
stdClass - 使用
SoapVar - 使用
SoapParam - 使用简单数组
- 双包装数组
- 以上的很多组合。
我尝试过调用$client->__soapCall('LogOn', [milliontries]) 和$client->LogOn([milliontries]) 之类的函数
...没有用,请帮忙。
更新:
我终于设法得到一个不同的错误(这表明至少我遇到了一些稍微不那么错误的错误)。我的代码现在看起来像这样:
$response = $client->LogOn(array('logon' => array('Username' => 'test','Password' => 'test')));
这给了我一个关于 LogOnType 不受支持的错误(在丹麦语中,这表明至少我现在与服务器有某种连接)。用户名和密码数组没有任何作用,我可以替换一个空字符串得到相同的结果,不同的是小写的logon。
如果有人可以设置一个给出错误incorrect username or password 的工作示例,我将永远感激不尽...但任何指针将不胜感激。
据我了解,wsdl 提供了执行此操作所需的所有信息,我只是太喜欢[your_pick] 来获取它...?
【问题讨论】: