我一直在使用依赖于 NuSOAP 的 PHP4 编写脚本。现在,我正在尝试将其移至 PHP5,并在那里使用对 SOAP 的内置支持。
$wsdlPath = ""; // I have obviously set these variables to something meaningful, just hidden for the sake of security
$apiPath = "";
$username = "";
$password = "";
// PHP5 style
$client = new soapclient($wsdlPath, array('login'=>username,
'password'=> $password,
'soap_version'=> SOAP_1_2,
'location'=> $apiPath,
'trace'=> 1));
// PHP4/NuSOAP style
$client = new soapclient($wsdlPath, true);
client->setEndpoint($apiPath);
$client->setCredentials($username, $password);
$client ->loadWSD);
PHP5 版本抛出以下异常堆栈跟踪:
EXCEPTION=SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://external-nbb.napi.norwegian.no.stage.osl.basefarm.net/api/napi1300?wsdl' in /home/eisebfog/public_html/database/norwegian.php:31
Stack trace:
#0 /home/eisebfog/public_html/database/norwegian.php(31): SoapClient->SoapClient('http://external...', Array)
#1 /home/eisebfog/public_html/database/index.php(53): require_once('/home/eisebfog/...')
#2 {main}
现在,NuSOAP 版本确实可以工作,而纯 PHP5 则不行——不需要脑外科医生就可以发现我做错了什么。我可以访问 .htaccess 文件,并通过 phpinfo() 确保我正在正确运行 NuSOAP 并在我应该运行 PHP5 时运行 PHP4/Nusoap。
基本上,我对 Web 服务和肥皂不是很好 - 但如果有人有任何想法,我将不胜感激任何关于我做错了什么以及如何在 PHP5 中迁移到本机肥皂的意见。顺便说一句,我首先希望这一举措的原因是假定在本地肥皂中节省资源。我也很感激这两个解决方案之间的基准测试链接。