Summary: PHP’s SOAP client was throwing an extremely unhelpful error: Error Fetching http headers. It turns out that it was a simple case of a slow SOAP server, and increasing the defaultsockettimeout in php.ini to 120 fixed it.
Problem: My very first experience with SOAP was failing. I couldn’t figure out why one request (getVersion) worked while another (getUserList) gave the above cryptic error.
Solution: After trying in vain to get useful information out of Apache and PHP, I installed Wireshark to sniff my network traffic. I could see the response coming in just fine, but it was only when I realized that it was coming in almost 100 seconds after the request that I became suspicious. Checking my php.ini, I found that the defaultsockettimeout was set to 60 seconds. I upped it to 120 and the problem was resolved.
Discussion: I probably should have thought of a timeout earlier. It felt like a timeout, but the strange message about headers caused me to bash my head against a wall for the better part of a workday.
Using the SOAP client’s connection_timeout option in this case would most likely not work because this is not a connection timeout—the TCP connection is made just fine—but rather that the server takes too long to form its HTTP/SOAP response. This is why the call to getVersion ran without trouble while getUserList did not; getUserList had a much longer execution time on the server.