9

I've developed some code which uses the NuSoap classes for PHP to call a soap web-service. I'm using NuSoap rather than the PHP 5 native classes mainly because I don't want to add an extra prerequisite when this code is installed on a shared web server. The code works fine on my machine:

require DOCROOT.'modules/nbn_species_dict_sync/lib/nusoap.php';
$client = new nusoap_client('http://www.nbnws.net/ws_3_5/GatewayWebService?wsdl', true);
$query1 = '<TaxonReportingCategoryListRequest xmlns="http://www.nbnws.net/TaxonReportingCategory" registrationKey="'.$key.'"></TaxonReportingCategoryListRequest>';
$response = $client->call('GetTaxonReportingCategoryList', $query1);

When I put this up on a virtual server rather than running it locally, the last line just hangs for about 10 seconds then PHP bombs out. No exception is raised and there is no PHP error (I've tried using try..catch and set_error_handler just to be sure).

My first reaction was that this might be a firewall running on the server blocking outgoing requests, but I am successfully using cUrl elsewhere for requests and I am pretty sure there is no firewall running here. Calling $client->use_curl does not make any difference to the NuSoap call though, it still does not work.

Any ideas why this might be occurring would be much appreciated.

Johnvb
  • 91
  • 2
  • Most likely memory_limit setting is different on localhost and server, and server exhaust the memory. – Maxim Krizhanovsky Oct 11 '11 at 11:34
  • Thanks for the suggestion. I've upped memory limit to 96M, but this only worked if I also called $client->setGlobalDebugLevel(0). 64M was not enough even with debugging turned off. I've just checked and the web service is responding with ~ 2MB of data. It seems odd that the memory usage is so high in this case. – Johnvb Oct 11 '11 at 12:26
  • I am likewise experiencing a similar issue. I have a 5mb data response from a webservice that nuSOAP wants to take up more than 256mb of memory to handle. – Travis Nov 03 '11 at 15:10
  • i've had similar problems and gave up on production server, gonna try this out – max4ever Nov 07 '11 at 14:27
  • Try accessing the url on the browser to the wsdl file from your local machine, as well as from the virtual machine. Do you get the wsdl content, or a gateway timeout. This might tell you what is wrong. – iWantSimpleLife Nov 09 '11 at 07:14
  • So I finally got it working, but I didn't solve the problem. The memory hogging issue specifically comes from the xml parsing section of nuSOAP, but figuring out what/why in that was more than I was willing to do. We tried culling all extraneous characters and data from the response, but my solution was ultimately to break the request into smaller pieces that were displayed incrementally to the user as they loaded. – Travis Jan 04 '12 at 13:28

2 Answers2

2

If you're out of troubleshooting ideas, and assuming you are running on Linux, you can watch the system calls by using strace. The calls can look pretty cryptic, but sometimes you can see what system call its hanging on, then Google that call for more info.

strace -p processid

Or if you want to trace your script from start of execution to finish and dump to an output file:

strace -o trace.txt myscript.php

Here is a good strace tutorial.

Banjer
  • 7,457
  • 4
  • 42
  • 61
0

Can you make sure that www-data has (permission to) access to

DOCROOT.'modules/nbn_species_dict_sync/lib/nusoap.php' ?

Or can you try to copy nusoap to another directory?

Or can you try to run it from command prompt as root user?

By the way, what kind of error/warning are you getting?

sankar d.
  • 51
  • 3