PHP Soap and chunked response, how to capture chunks

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi everbody,

At these days I am having problems with chunked responses via PHP's
soap extension (using __soapcall). I have a search interface
containing a soapclient to the Pubmed literature service, requesting
information via their entrez Eutils wsdl service. Since about one week
now, some xml responses of certain search requests seem to be chunked.
I am not able to further process the xml because it is invalid. I
never had that problem before.

Can anybody point me to an PHP code example of how to deal with
chunked responses from __soapcall()/__getLastResponse() fct., How do I
capture the stream and get one response string either as an array or
one xml string. I've been searching for examples but seem not to find

I want to stick with the internal PHP soap extension, because it is
fast. NuSoap is to slow for my needs.

Thanks in advance for your help!

Andreas W Wylach

Re: PHP Soap and chunked response, how to capture chunks

Quoted text here. Click to load it

As I found out digging thru the in the PHP SOAP extension C-Source
(file php_http.c) it seems that chunked responses are recognized
within function get_http_body() and concatenated to one response
string. So it also gets clear to me that I even can not overwrite the
transport layer with any php soap method because I can not get down to
the transport layer. Fact is something breaks some of my responses and
return back an inclomplete xml string. I also though it could be a bug
but I can not find any similar problems reported by other people using
the PHP soap extension.

Or is there anyboby out there that has similar problems with soap
responses using wsdl services? Anybody has a hint what else I can try?
I don't know if I can overwrite the transport layer (for example with
Curl, or whatnot) and work out the response stream myself.

Once again, any hint is very welcome ... I really need to fix the
problem asap...


Re: PHP Soap and chunked response, how to capture chunks

Andreas W. Wylach skrev:

Quoted text here. Click to load it

Just a thought. Have you tried calling __getLastResponseHeaders() and
looked for the "Content-Length" header?

If "Content-Length" matches the actual length of the content, the
problem looks like a server side problem - otherwise the server did (or
intended to) send you more than you received.



Re: PHP Soap and chunked response, how to capture chunks

Quoted text here. Click to load it

Jonathan, thanks for your answer.

Yes, I switched off compression mode and compared the content-length
in the "LastResponseHeaders" with the actual string length returned by
the __getLastResponse() Function. The values are equal. I haven't
thought of your idea ... So it seems NCBI sends more content than the
values in the headers say.

I just wonder why that is happening with a few searches (search terms)
and not with every search I request, almost like sporadic. One
intersting thing I discovered is, if I do not request 20 records (that
is the amount i request per search since I run the search interface),
say I just request 5 records (less content) I get no error. All that
is really annoying. Taking a look at the response I also thought there
is an problem with the encoding (utf-8), because almost every
errornous response string misses just a few bytes at the end, the last
2 or 3 closing tags of the xml string are just cut off, maybe about
20-40 bytes. Umlauts within the xml string shows as <?> or just not
displayed properly. Switching to ISO-8859-1 (within Firefox Browser),
Umlauts show fine. It is confusing. I did not have that problem before
April 20 ... So do I have an encoding problem?

I also started to think about rewriting the complete search core with
sockets and handling the stream myself ...

Well, I guess I will have to email them again and ask if they can make
an investigation on the server side. Best is I also mail them the
search terms that I use to reproduce the error. Maybe it is a chance
to get finally a solution ...


Site Timeline