NuSOAP, PHP, Web service & a traumatic experience

Hey guys,
So I am trying to use NuSoap to connect throguh a webservice. I have two different services, one of them works and one of them doesnt. Is the URL for the one that doesnt work is the one that does work.

If i use the products url it doesnt work, but if i start a nusoap_client with the references url it does work. The XML datasets are the same.

When i run the products I get an internal service error (500) and the following in the error logs:

(104)Connection reset by peer: FastCGI: comm with server "/var/www/fcgi/php-cgi" aborted: read failed, referer:
[Tue Jan 12 13:50:19 2010] [error] [client] FastCGI: incomplete headers (0 bytes) received from server "/var/www/fcgi/php-cgi", referer:

Any ideas anyone?? This is my first time using this so i dont even know how to dbug it really...

P.S. i have googled.. the closest ive come is that it might be something to do with FastCGI and i should turn that off but i dont really know how etc...

$client = new nusoap_client('', true);

		$result = $client->call('GetReferences');
		if ($client->fault) :// Check for a fault
		else:// Check for a fault
			$err = $client->getError();
			if ($err):// Check for errors
			else:// Check for errors
			endif;// Check for errors
		endif;// Check for a fault

Open in new window

Who is Participating?
Beverley PortlockCommented:
When I have seen this sort of stuff before from FastCGI it usually means that a runtime library is whacked. Unfortunately you cannot simply change "FastCGI" to something else unless you control the server as it is a way of running PHP on a machine.

Your starting point here might be to ask your hosting service about the error and if all the relevant libraries are up to date.

Failing that, try using SOAPClient if it installed rather than NuSOAP
andoneknightAuthor Commented:
hey so i have dbugged it as far as i can and have got to the point of selecting only a certain number of records in the webservice. When i get to 229 records i get the following error:

Memory limit exhausted (16mb) tried to allocate (14.5mb) etc... you know th emessage!

The thing is there is only 229 records so i dont believe by anny stretch of my imagination that its reaching 16mb..!!!!!! its actually around 300kb.

So possibly memory leaking somewhere?
Anyone have any similar problems?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Beverley PortlockCommented:
You have to be very careful when working in small memory footprints as PHP has a nasty habit of duplicating storage. For instance if I do this

$arr = array( of, say, 1000 elements);

foreach( $arr as $value )
    $value = "1234";

None of the values in $arr will be changed because PHP copies it first and makes a duplicate which it then processes.  So if you use your 300KB data in two FOREACHs you will now have 1MB of data stored. It would not take too long to use the remaining space. To avooid this we use references

foreach( $arr as & $value )
    $value = "1234";

Make sure that you use references where ever you can
andoneknightAuthor Commented:
Well, im using the NuSOAP library so im not actually doing any coding myself except for the calling of the web service.

does what you suggested affect nusoap? Do you know if it was written like that? I just get the feeling it must be something basic that ican change coz there really isnt a lot of data.. what soap libraries do other people use? as you mentioned does everyone use SOAPClient? If it was a problem with NuSOAP surely there would be numerous things about it?
Beverley PortlockCommented:
To be honest 16M is a small memory footprint.  I typically use 128M as a minimum. I did some digging for memory leaks on NuSOAP and came across a posting about 4 months old that said

For production purposes (or if you are processing a lot of data) you just need to change your $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel variable from 9 to 0.

Depending on your version of NuSOAP, this variable definition may be located in the nusoap.php file at the top.

$GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = 0;

NuSoap appears to keep track of debug information by simple appending to this variable.

So I suggest you try it - 30 seconds later you will know if it works. If not then try looking at SOAPClient. If that does not work, contact your hoster and ask for more memory. If that does not work then you need to consider a different host if this is a major problem for you.
andoneknightAuthor Commented:
Many thanks for your post. I in the end went through the entire nusoap library returning at various points to find where the error was and i did get to the point at which the debug information was just appended to the variable. I tried stopping it appending and it helped a bit but was still a memory hog. Ultimately I ended up just using SOAPClient as seemed the easiest thing to do... Why would you need NuSOAP anyway if SOAPClient is installed and provides the functionality needed!!!

Many thanks for your responses again.
andoneknightAuthor Commented:
Thanks for your help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.