我一直在使用依赖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服务和 SOAP 不是很好-但是,如果有人对我有什么想法,我将不胜感激,感谢我在做错事情以及如何在PHP5中使用 native SOAP 方面的任何投入。顺便说一句,首先,我要此举的原因是假定可以节省天然 SOAP 的资源。我也非常感谢这两个解决方案之间的基准测试链接。

最佳答案

确保NuSoap和PHPv5-SOAP在同一服务器上运行。如果我不是完全错误,那么两个库都使用相同的类名。如果您确保不包含任何NuSopa文件,它可能会更好地工作?并验证是否已加载SOAP库:

if(!extension_loaded('soap')){
  dl('soap.so'); // Actually a deprecated method. See "notes" at http://no.php.net/dl
}

我猜您引用的版本字段定义为“SOAP 1.1”还是类似的?

最好的祝愿 :)

顺便说一句:你在做什么?从飞行员到机场的延误交流?还是可以减少Osl行李运送等待时间的网络服务? :p

10-07 14:03