我们正在运行 PHP 5.3.18,由于某些奇怪的原因,我无法安装 php-soap,因此我无法使用 SoapClient 类...
我现在正在使用最后一个 nusoap(应该与 php 5.3.18 兼容)并将代码从 SoapClient 转换为 nusoap_client。
此代码使用 SoapClient 并完美运行
$s_WSPROTOCOL = 'https';
$s_WSHOSTNAME = 'xxxxxxxx.yyyyyy.tdl';
$s_WSPORT = '';
$s_WSPATHNAME = 'webservices/service.asp?WSDL';
$s_WSTIPOOP = 'MyFunction';
$parameters['Username'] = '999';
$parameters['Login'] = 'Master';
$parameters['Password'] = 'universe';
$parameters['IdServ'] = '5';
$parameters['IdCard'] = '555';
$parameters['Controllo'] = '';
echo $s_WSTIPOOP."<br />";
echo $s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME."<br /><br /><br />";
try
{
$SOAP = new SoapClient($s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME, array('trace' => 1));
$result = $SOAP->__soapCall($s_WSTIPOOP, array("parameters" => $parameters), null);
foreach ($result as $key => $value)
{
echo "<b>".$key."</b><br />";
print_r($value);
echo "<br />";
}
}
catch (SoapFault $e)
{
echo "<b>".$e->faultstring."</b>";
}
nusoap 中的此代码返回
[faultcode] => soap:Client
[faultstring] => Server did not recognize the value of HTTP Header SOAPAction: .
[detail] =>
这里的代码
require("nusoap/lib/nusoap.php");
error_reporting(E_ALL ^ E_NOTICE);
$ERROR_MSG = '';
$s_WSPROTOCOL = 'https';
$s_WSHOSTNAME = 'xxxxxxxx.yyyyyy.tdl';
$s_WSPORT = '';
$s_WSPATHNAME = 'webservices/service.asp?WSDL';
$s_WSTIPOOP = 'MyFunction';
$parameters['Username'] = '999';
$parameters['Login'] = 'Master';
$parameters['Password'] = 'universe';
$parameters['IdServ'] = '5';
$parameters['IdCard'] = '555';
$parameters['Controllo'] = '';
echo $s_WSTIPOOP."<br />";
echo $s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME."<br /><br /><br />";
$client = new nusoap_client($s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME);
$result = $client->call($s_WSTIPOOP, $parameters, '');
if ($client->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
}
}
错误在哪里?我正在阅读来自 nusoap 源的代码,尝试使用不同的参数但没有成功