views:

5025

answers:

3

Hi,

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

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}

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.

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.

+1  A: 

Without testing it, I have two suggestions:

First, put your error_reporting to the highest possible (before creating the SoapClient):

error_reporting( E_ALL );

If there's something wrong with the authentication on the server's side, PHP will throw warnings. 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. Theoretically, the wsdl tells your client, where the endpoint of the operations is, so you don't have to bother.

Cassy
+1  A: 
qualbeen
A: 

We had very similar problems with PHP5 built-in SOAP client trying to consume a .NET-based Web-service. Also WSDL parsing failed reporting invalid schema. Putting the schema definitions into a single local file didn't help.

We gave up trying and switched to NuSOAP, which did work.

However, NuSOAP is far from perfect also. Right now I get into out-of memory situation during the parsing of 1MB+ responses. 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.

Ivan Krechetov