tags:

views:

14

answers:

1

is it possible, using PHP SoapServer class, to stream data back to the client along the computation?

i know this is possible using ASP.NET

http://msdn.microsoft.com/en-us/library/aa528818.aspx

if not, is it possible to implement it? as far as i understand the php soap facilities, they only allow my functions to return a big chunk of data, and once completed the library will convert it in a big soap message... :-/

thanks in advance :)

A: 

The short answer is that this is not possible with the SoapServer class.

The current implementation builds the resulting XML document as it checks parameters for validity (to make sure you're not sending crazy invalid SOAP parameters).

While it may be possible to implement what you're asking in the extension, I would be a significant change, as it would have to loop twice over the parameters, once to check for validity (so they can throw a Soap Fault), and then a second time to serialize to the client.

It is also possible to implement this in userland in your PHP script, but this would require you to serialize all of you response data by hand (since the builtin class does not expose this functionality to you). This is not a bad option if you control both sides of the request (client and server), and don't need to take advantage of any "advanced" soap features the server library provides.

For this you would just send a standard soap XML header, then loop over your data converting it to XML as you write it directly to the client.

Keith Minkler
The soap extension could take a stream instead of a string and then read from the stream, encode and send to the client until the stream is over. I don't know how hard it would be (I'm not familiar with the code base), but I don't get your double loop argument.
Artefacto
The problem would be that the library could not detect errors in encoding in time to do anything about (i.e. convert the response to a SOAP Fault), since it would have already sent output and headers. A soap fault should send a 500 status code, which it could not do if it started sending output before it validated all the parameters in the result.
Keith Minkler