NuSOAP, PHP, Web service & a traumatic experience

Posted on 2010-01-12
Medium Priority
Last Modified: 2013-11-18
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.
http://www.domain.com/service/WEBSERVICEGETPRODUCTS.ASMX?op=GetProducts Is the URL for the one that doesnt work
http://www.domain.com/service/WEBSERVICEGETREFERENCES.ASMX?op=GetReferences 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: http://3100959.test.prositehosting.co.uk/cratima/admin/import_nusoap
[Tue Jan 12 13:50:19 2010] [error] [client] FastCGI: incomplete headers (0 bytes) received from server "/var/www/fcgi/php-cgi", referer: http://3100959.test.prositehosting.co.uk/cratima/admin/import_nusoap

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('http://www.domain.com/service/WEBSERVICEGETPRODUCTS.ASMX?WSDL', 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

Question by:andoneknight
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26293469
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



Author Comment

ID: 26294424
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?
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26294603
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

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?


Author Comment

ID: 26294939
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?
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26296233
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.
LVL 34

Accepted Solution

Beverley Portlock earned 2000 total points
ID: 26296238

Author Comment

ID: 26299418
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.

Author Closing Comment

ID: 31676085
Thanks for your help!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question