Set KeepAlive Header in PHP SoapClient

8. March 2010 20:30

Some of you may have read my first post about some problems with PHP comminucating with a WCF Web Service (or vice versa). Well I was working on another issue with it as well just recently. We needed a way to turn off KeepAlives, set Connection to Close, (Connection: Close) in the HTTP header while PHP was sending the call to the web service. After much research it turns out the standard PHP SoapClient object can't do this.

What I did find out though, is that PHP was capable of doing this, but in PHP you would need to use curl when making the request.  curl allows you to set the HTTP Headers of a POST.  Which in this case, is excatly what was needed!

So this code concept will allow you to set the HTTP Headers, turn off Keep Alive ("Connection: Close") when making a POST to a WCF Service.

Note: we are still using the SoapClient object and override the __doRequest method just as in the previous post. Also, the setup/configuration is still the same as in the previous post.


Anyway, I know I'm not a PHP developer, but wanted to share this with everyone since it has to do with another platform communicating with a WCF Web Service.




blog comments powered by Disqus

My Random Thought

I think the OCW is a great thing to have available to those who are in school, just finished school or just want to educate themself

John On Twitter