从NuSOAP迁移到PHP5 SOAP

问题描述:

我一直在使用依赖于NuSOAP的PHP4编写脚本.现在,我试图将其移至PHP5,并在那里使用对SOAP的内置支持.

I have been working on a script with PHP4 that relies on NuSOAP. Now, I'm trying to move this to PHP5, and use the buildin support for SOAP there.

$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版本抛出以下异常堆栈跟踪:

The PHP5-version throws the following exception stacktrace:

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.

Now, as the NuSOAP version does work, and the pure PHP5 doesn't - it doesn't take a brain surgeon to figure out I'm doing something wrong. I have access to the .htaccess file, and through phpinfo() I have made sure that I'm running NuSOAP properly and running PHP5 when I should, and PHP4/Nusoap when I should.

基本上,我对Web服务和肥皂不是很好-但是,如果有人有任何想法,我将感谢您对我做错的事情以及如何在PHP5中使用本机肥皂的任何投入.顺便说一句,首先,我要此举的原因是假定可以节省天然肥皂的资源.我也非常感谢这两个解决方案之间的基准测试链接.

Basically, I'm not very good with web services and soap - but if anyone has any ideas, i'd appreciate any input on what I'm doing wrong and how I can move to the native soap in PHP5. Btw, the reson I want this move in the first place is the assumed resource savings in native soap. I'd appreciate any links to benchmarks between these two solutions too.

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

Make sure NuSoap and PHPv5-SOAP are running on the same server. If I'm not totally wrong, both libraries uses the same class-name. Maybe it will work better if you make sure none NuSopa-files are included? And also verify that the SOAP-library are loaded:

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

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

I guess the version-field you refer to is defined as "SOAP 1.1" or similiar?

最良好的祝愿:)