我是 Soap Web Services 的初学者。我查看了与我相关的所有问题和答案,但他们有不同的场景和代码,它们似乎与我的要求不符。

我使用第三方创建的 Web 服务进行产品列表。我想获取一些数据,以便我可以了解 Webservices 如何工作的基本工作流程。这是我目前的代码

require_once('nuSOAP/lib/nusoap.php');

$wsdl   = "http://ws.anchordistributors.com/anchorwebservice.asmx?wsdl";
$client = new nusoap_client($wsdl, 'wsdl');

// Input params
$username = "mylogin_id";
$password = "mylogin_password";

// In this demo, we use json data , you can use any other data format for same
$json     = '{"param1":"value1","param2":"value2"}';

$client->setCredentials($username, $password);
$error = $client->getError();

if ($error)
{
    echo $error; die();
}

$action = "GetCountries"; // webservice method name

$result = array();

if (isset($action))
{
    $result['response'] = $client->call($action, $json);
}

echo "<h3>Output : </h3>";
print_r ($result['response']);
echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";

这就是我要回来的:

输出:

数组([3] => soap:Server [4] => System.Web.Services.Protocols.SoapException:服务器无法处理请求.---> System.NullReferenceException:对象引用未设置为对象的实例.在 AnchorWebservice.AnchorWebservice.AuthenticateUser(String sFunction)AnchorWebservice.AnchorWebservice.GetCountries() ---结束内部异常堆栈跟踪--- [5] =>)请求

POST /anchorwebservice.asmx HTTP/1.0 主持人:ws.anchordistributors.com User-Agent:NuSOAP/0.9.5(1.123)Content-Type:text/xml; charset=ISO-8859-1 SOAPAction:“http://tempuri.org/AnchorWebservice/AnchorWebservice/GetCountries”授权:基本 ODI1NjQ3OkVJTExDODI1 Content-Length:401

{ “参数 1”: “VALUE1”, “参数 2”: “VALUE2”}

响应

HTTP/1.1 500 内部服务器错误。连接:关闭日期:2017 年 10 月 6 日星期五 18:47:28 GMT 服务器:Microsoft-IIS/6.0 X-Powered-By:ASP.NET X-AspNet-Version:1.1.4322 Cache-Control:私人 Content-Type:text/xml; charset=utf-8 Content-Length:744

soap:Server System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.NullReferenceException:对象引用未设置为对象的实例。在 AnchorWebservice.AnchorWebservice.AuthenticateUser(String sFunction)
在 AnchorWebservice.AnchorWebservice.GetCountries() ---内部异常堆栈跟踪结束---

我不知道为什么这会产生什么逻辑问题。作为初学者,我不知道问题的意义。我只是希望能够使用GetCountries方法来获取国家/地区数组。