简体   繁体   English

从NuSOAP迁移到PHP5 SOAP

[英]Moving from NuSOAP to PHP5 SOAP

I have been working on a script with PHP4 that relies on NuSOAP. 我一直在使用PHP4的脚本,它依赖于NuSOAP。 Now, I'm trying to move this to PHP5, and use the buildin support for SOAP there. 现在,我正在尝试将其移至PHP5,并在那里使用对SOAP的buildin支持。

$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);

The PHP5-version throws the following exception stacktrace: 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}

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. 现在,由于NuSOAP版本确实有效,纯PHP5没有 - 它不需要脑外科医生弄清楚我做错了什么。 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. 我可以访问.htaccess文件,并通过phpinfo()确保我正确地运行NuSOAP并在应该运行PHP5时运行PHP5和我应该运行的PHP4 / Nusoap。

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. 基本上,我对网络服务和肥皂并不是很好 - 但是如果有人有任何想法,我会很感激我对错误以​​及如何在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. 我也很欣赏这两个解决方案之间的基准测试链接。

Make sure NuSoap and PHPv5-SOAP are running on the same server. 确保NuSoap和PHPv5-SOAP在同一台服务器上运行。 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? 如果确保没有包含任何NuSopa文件,它可能会更好吗? And also verify that the SOAP-library are loaded: 并验证是否加载了SOAP库:

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

I guess the version-field you refer to is defined as "SOAP 1.1" or similiar? 我想你引用的版本字段被定义为“SOAP 1.1”或类似?

Best wishes :) 最好的祝愿 :)

Btw: what are you working on? 顺便问一下:你在做什么? Exchange of delays from the pilot to the airport? 从飞行员到机场的交换延误? Or perhaps a webservice which will decrease the waiting-time on luggage delivery at Osl? 或者也许是一个减少奥斯陆行李托运等待时间的网络服务? :p :p

Without testing it, I have two suggestions: 没有测试,我有两个建议:

First, put your error_reporting to the highest possible (before creating the SoapClient): 首先,将error_reporting置于尽可能高的值(在创建SoapClient之前):

error_reporting( E_ALL );

If there's something wrong with the authentication on the server's side, PHP will throw warnings. 如果服务器端的身份验证出现问题,PHP将发出警告。 In most of the cases, it will tell you, what has gone wrong. 在大多数情况下,它会告诉你,出了什么问题。

Second: I don't know if you can specifiy the 'location' option together with an URL to a wsdl. 第二:我不知道你是否可以指定'location'选项和wsdl的URL。 Theoretically, the wsdl tells your client, where the endpoint of the operations is, so you don't have to bother. 从理论上讲,wsdl会告诉您的客户端操作的端点在哪里,因此您不必费心。

We had very similar problems with PHP5 built-in SOAP client trying to consume a .NET-based Web-service. 我们遇到了与PHP5内置SOAP客户端试图使用基于.NET的Web服务非常相似的问题。 Also WSDL parsing failed reporting invalid schema. WSDL解析也无法报告无效架构。 Putting the schema definitions into a single local file didn't help. 将模式定义放入单个本地文件中没有帮助。

We gave up trying and switched to NuSOAP, which did work. 我们放弃了尝试并切换到NuSOAP,它确实起作用了。

However, NuSOAP is far from perfect also. 然而,NuSOAP也远非完美。 Right now I get into out-of memory situation during the parsing of 1MB+ responses. 现在,在解析1MB +响应期间,我遇到了内存不足的情况。 Erasing all the nasty debug code helped a little, but not radically. 擦除所有讨厌的调试代码有点帮助,但不是根本。

Thus, looks like there's no 100% interoperable/functional SOAP client implementation in PHP at the moment. 因此,看起来目前在PHP中没有100%可互操作/功能的SOAP客户端实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM