• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 608
  • Last Modified:

PHP new SOAP Client

I have a small PHP file that is used to retrieve data from a 3rd party via SOAPClient process every 10 seconds or so. To do this I have the PHP file loaded each time to trigger another SOAP request. My hosting company says that my site is using extraordinary resources and I wonder what I can do to reduce any strain on the hosting. I have 2 simple questions.

1. The file establishes a 'new SOAPClient' every time it loads but is always the same 3rd party WSDL file. Do I need to do this each time and, if so, does this action require 'closing' at the end of the PHP file (like using mysql_close after accessing a database)?

2. Is there a simpler, more efficient way using PHP SOAPClient to get this data every 10-15secs?

If the answer to no1 is proven to be 'yes - it should be closed' then there is no need for an answer to no2.

Many thanks.
  • 3
  • 3
1 Solution
1. There's no requirement that you need to close it.  the memory should be clearing when the script itself closes.  mysql_close itself is not really that useful.

2.  If you are pulling data every 10-15 seconds, then you may want to rethink the way you are doing this rather than ask how SOAPClient could be more efficient.  A few suggestions come to mind.  

First, why not leave the same instance of the app running for a few minutes at a time and just have it sleep 15 seconds between sending the requests?

Second, you could try to use WSDL caching, but I doubt this is much of the source of the high utilization.

Third, it might be more a question of what you do with the XML returned or how big it is to begin with.  The XML processor is heavily memory intensive in PHP.  In the case of one app, we are using regex to clean up their sloppy repetitiveness in order to handle things more smoothly.

robertybobAuthor Commented:
Thx Virmaior.

The data would need to be retrieved for very long periods (hours) so I assumed that if the PHP file contains 'sleeps' before running a function to check data again it would never actually finish loading?

The WSDL file will be big but the data pulled fairly concise.

The main query was about the possible closing of SOAPClients so thats useful. I'm currently moving almost all calcs/processing to javascript as opposed to PHP and have the actual PHP flie requested down from 30k to less than 2k so this will certainly help bandwidth issues so will see about resources in time.

I'll close this question in the morning to allow others a bit of time to see it in case anything extra to be added.

Thanks again
I am not sure what you mean by
"The data would need to be retrieved for very long periods (hours) so I  assumed that if the PHP file contains 'sleeps' before running a function  to check data again it would never actually finish loading?"

you stated that
"I have a small PHP file that is used to retrieve  data from a 3rd party via SOAPClient process every 10 seconds or so"

what I am suggesting is that rather than start a new php script every 10 seconds, you use the same script for say 5 minutes to pass data and then start a new one...


if ran continuously, it would never finish loading, but by running it for longer than one pull, you could have it keep running and consume less resources.


one other question.  how big is the data that you are pulling down?


finally, it's not exactly clear to me why the appropriate response would be closing the question as I am answering your question.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

robertybobAuthor Commented:
Sorry - when I said 'close' that meant accept answer and move on since it seems that the SOAPClient is coded correctly......

Whilst the file is small and the retrieved data per request is small, the data would be required to be retrieved every 10sec or so for 8-10 hours minimum every day. I can see if it would be possible to run the same file for 10-20 retrievals during each load but might not be feasible - tho is an interesting thought.

The response data from the WDSL is probably not more than 1k in size and in many cases much less.

yeah, maybe your host just sucks?
that's really not that much load.

robertybobAuthor Commented:
Thx - will see how it goes with the reduced PHP file size
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.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now