Re: [SOAP] Array in PEAR::SOAP
| From: | Shane Caraveo | Date: | Tue, 18 Jun 2002 21:51:18 +0000 |
| Subject: | Re: [SOAP] Array in PEAR::SOAP | ||
| References: | 1 2 3 4 5 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-134@lists.php.net to get a copy of this message | ||
Then we have a bug. Are you up to date with the latest from cvs?
Shane
Luis Barrios wrote:
When do that, I have in the response: <NewsList xsi:type="SOAP-ENC:Array"SOAP-ENC:arrayType="xsd:anyType[6]" SOAP-ENC:offset="[0]"><news> ..... and this is not what I want because I think that xsd:anyType[6] it is not very good... Luis "Shane Caraveo" <shane@caraveo.com> wrote in message news:3D0FA210.8040109@caraveo.com...You're giving the wrong type. $arr = array(); for( . . . ) {think), I$arr[] = new SOAP_Value("news", "{urn:AldiaService}news", array( new SOAP_Value('id', 'int', $...), new SOAP_Value('title', 'string', $...), new SOAP_Value('audiorm', 'string', $...) ));} return new SOAP_Value("NewsList", "Array", $arr); Shane Luis Barrios wrote:Ok, I saw the server_round2_base.php, echoStructArray and a part of the problem was resolved, but I have WSDL, so I have my namespaces (Iarray(made: $arr = array(); for( . . . ) { $arr[] = new SOAP_Value("news", "SOAPStruct", array(new SOAP_Value('id', 'int', $...), new SOAP_Value('title', 'string', $...), new SOAP_Value('audiorm', 'string', $...) ));} return new SOAP_Value("NewsList", "Array", $arr); // If I use return $arr; I will lost the name 'NewsList' And the WSDL is: <types> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"targetNamespace="urn:AldiaService"><xsd:complexType name="news"> <xsd:all> <xsd:element name="id" type="xsd:int"/> <xsd:element name="title" type="xsd:string"/> <xsd:element name="audiorm" type="xsd:string"/> </xsd:all> </xsd:complexType><xsd:complexType name="AldiaListaResultArray"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <xsd:attribute ref="soapenc:arrayType"wsdl:arrayType="typens:news[]"/></xsd:restriction> </xsd:complexContent> </xsd:complexType></xsd:schema> </types> <message name="ListarNoticiasResponse"><part name="NewsList" type="typens:AldiaListaResultArray"/></message> <portType name="AldiaServicePort"> <operation name="aldialista"><input message="typens:ListarNoticias"/> <output message="typens:ListarNoticiasResponse"/></operation> </portType> and with the new changes the Response is: <ns6:aldialistaResponse> <NewsList xsi:type="SOAP-ENC:Array"SOAP-ENC:arrayType="si:SOAPStruct[6]" SOAP-ENC:offset="[0]"><news xsi:type="si:SOAPStruct"> <id xsi:type="xsd:int">4980</id> <title xsi:type="xsd:string">....</title> <audiorm xsi:type="xsd:string">...</audiorm> </news> <news xsi:type="si:SOAPStruct"> ..... I can change the line $arr[] = new SOAP_Value("news", "SOAPStruct",butfor $arr[] = new SOAP_Value("item", "SOAPStruct", array(What is the best choice, Thanks a lot, Luis "Shane Caraveo" <shane@caraveo.com> wrote in message news:3D0F890B.1020100@caraveo.com...Luis Barrios wrote:Hi, I have a services with PEAR::SOAP, the response is a array of structIcorrect,think that the response is not correct: <ns6:newslistResponse> <NewsList xsi:type="SOAP-ENC:Array"SOAP-ENC:arrayType="xsd:anyType[6]" SOAP-ENC:offset="[0]">I think that SOAP-ENC:arrayType="xsd:anyType[3]" it is notmaybe something like SOAP-ENC:arrayType="xsd:news[3]" and the element <news> something like: <news xsi:type="......"> but I dont know how I can change that in the server-side. Please, help me, LuisThere is an example in the server_round2_base.php, echoStructArray. 'news' is not in the namespace that the xsd prefix represents, so you cannot have xsd:news. You have to have your own namespace for the type. function getNewsList() { $newsList = array(); $newsItems = getYourNewsList(); if ($newsItems) { foreach($newsItems as $item) { $newsList[] = new SOAP_Value('item','{http://yournamespace/}news',$item); } return $newsList; } A namespace with be added to the envelope for http://yournamespace/, and the arrayType should end up being something like ns1:news[] Shane