Re: [SOAP] Problem with returning empty array

From: Date: Wed, 06 Aug 2003 02:20:26 +0000
Subject: Re: [SOAP] Problem with returning empty array
References: 1  Groups: php.soap 
Request: Send a blank email to php-soap+get-928@lists.php.net to get a copy of this message
At 01:16 06/08/2003, Javier Muniz wrote:
Hi, I'm getting an error from VB.NET when consuming a PEAR::SOAP webservice that sometimes returns an empty array. Everything works fine when the array is populated, however when the array is empty I get an xml error, the wire is: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4="urn:EncoderIntegrator" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns4:getControlMessagesResponse> <messages xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="[0]"/> </ns4:getControlMessagesResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Now, I'm no expert but I don't believe that '[0]' is valid for an arrayType, is this correct? Any ideas on why that's getting in there?
Hi Javier and all, The reason this happens is because at serialise-time, if no WSDL file is being used by the PEAR::SOAP server, PEAR::SOAP does not use the information from __typedef to serialise type information, but instead tries to guess the types from the data supplied (ie. your array). When the array is populated, it might be able to figure out its type from its contents, but when empty, it has no data to examine and only knows it is an array. As the array type is never discovered during serialisation, SOAP-ENC:arrayType gets erroneously set to [0]. One of the interop patches I have submitted for 0.8 creates internal WSDL data for anything you add with addObjectMap, as long as the object has both a __dispatch_map and a __typedef. This will cause PEAR::SOAP to refer to your type definitions at serialise-time and should make your problem go away. I should probably make a patch to set 0-length PHP value arrays to "xsd:anyType" so that we're not creating malformed SOAP-ENC:arrayType attributes in future. Hope this helps. Best, Chris.
Thanks! -Javier -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.soap (#928) next »