From: Scott N. <sni...@sc...> - 2005-04-27 19:37:28
|
Here's the schema for Apache SOAP types: <schema xmlns=3D"http://www.w3.org/2001/XMLSchema" targetNamespace=3D"http://xml.apache.org/xml-soap" elementFormDefault=3D"unqualified" attributeFormDefault=3D"unqualified"> <complexType name=3D"Vector"> <sequence> <element name=3D"item" minOccurs=3D"0" maxOccurs=3D"unbounded" = nillable=3D"true" /> </sequence> </complexType> <complexType name=3D"Map"> <sequence> <element name=3D"item" minOccurs=3D"0" maxOccurs=3D"unbounded"> <complexType> <sequence> <element name=3D"key" minOccurs=3D"1" maxOccurs=3D"1" /> <element name=3D"value" minOccurs=3D"1" maxOccurs=3D"1" = nillable=3D"true" /> </sequence> </complexType> </element> =20 </sequence> </complexType> </schema> To use this, you might want to use a standalone WSDL file, rather than = creating WSDL programmatically, so that you can just paste this schema = into the file. Scott Nichol Do not send e-mail directly to this e-mail address, because it is filtered to accept only mail from specific mail lists. ----- Original Message -----=20 From: "Mario" <ma...@un...> To: "Scott Nichol" <sni...@sc...> Sent: Wednesday, April 27, 2005 2:40 PM Subject: Re: [Nusoap-general] addComplexType problems with an = associative array > Hi Scott, >=20 > thank you. >=20 > But what can I do when I don't know how much key/value pairs my return = > array has? >=20 > Regards, > Mario >=20 > Scott Nichol schrieb: > > A PHP associative array corresponds to an XSD complexType, where the = names of the keys of the associative array are the names of the elements = of the complexType. > >=20 > > The array created in > >=20 > > array("ret_code"=3D>"200","ret_message"=3D"User Okay.") > >=20 > > corresponds to an XSD complexType like > >=20 > > <complexType name=3D"CheckUserReturn"> > > <all> > > <element name=3D"ret_code" type=3D"xsd:string"/> > > <element name=3D"ret_message" type=3D"xsd:string"/> > > </all> > > </complexType> > >=20 > > which you can define in NuSOAP with > >=20 > > $server->wsdl->addComplexType( > > 'CheckUserReturn', > > 'complexType', > > 'struct', > > 'all', > > '', > > array( > > 'ret_code' =3D> = array('name'=3D>'ret_code','type'=3D>'xsd:string'), > > 'ret_message' =3D> = array('name'=3D>'ret_message','type'=3D>'xsd:string') > > ) > > ); > >=20 > > Scott Nichol > >=20 > > Do not send e-mail directly to this e-mail address, > > because it is filtered to accept only mail from > > specific mail lists. > > ----- Original Message -----=20 > > From: "Mario" <ma...@un...> > > To: <nus...@li...> > > Sent: Wednesday, April 27, 2005 1:39 PM > > Subject: [Nusoap-general] addComplexType problems with an = associative array > >=20 > >=20 > >=20 > >>Hello, > >> > >>I have a problem creating my WSDL file since days. > >>I searched at Google and this mailing list archive but could'nt = solve my=20 > >>problem. > >> > >>The problem is that I don't know how to send an associative array as = the=20 > >>response to the client. > >> > >>This is my server: > >> > = >>/*---------------------------------------------------------------------= -*/ > >> > >>$server =3D new soap_server(); > >> > >>$server->configureWSDL('Nameserver', $NAMESPACE); > >>$server->wsdl->schemaTargetNamespace =3D $NAMESPACE; > >> > >>$server->wsdl->addComplexType( > >>'ArrayOf_xsd_string', > >>'complexType', > >>'array', > >>'', > >>'SOAP-ENC:Array', > >>array(), > = >>array(array('ref'=3D>'SOAP-ENC:arrayType','wsdl:arrayType'=3D>'string[]= ')),'xsd:string' > >>); > >> > >>function CheckUser($userid,$password,$userdata) { > >>// some checks here > >>return array("ret_code"=3D>"200","ret_message"=3D"User Okay."); > >>} > >> > >>$server->register('CheckUser', // method name > >>array( 'userid'=3D>'xsd:int', > >>'password'=3D>'xsd:string', > >>'userdata'=3D>'tns:ArrayOf_xsd_string' > >>), // input parameters > >>array('return' =3D> 'tns:ArrayOf_xsd_string'), // output parameters > >>$NAMESPACE, // namespace > >>'', // soapaction > >>'rpc', // style > >>'encoded', // use > >>'Checks the nameserver configuration for a domain name' // = documentation > >>); > >> > >>// Use the request to (try to) invoke the service > >>$HTTP_RAW_POST_DATA =3D isset($HTTP_RAW_POST_DATA) ? = $HTTP_RAW_POST_DATA : ''; > >>$server->service($HTTP_RAW_POST_DATA); > >> > = >>/*---------------------------------------------------------------------= -*/ > >> > >>This is my client: > >> > = >>/*---------------------------------------------------------------------= -*/ > >> > >>$client =3D new soapclient('http://myserver/server.php?wsdl', true); > >> > >>$result =3D $client->call('CheckUser', > >>array( 'userid' =3D> 123, > >>'password' =3D> "secret", > >>'userdata' =3D> array("Key1"=3D>"Value1","Key2"=3D>"Value2") > >>) > >>); > >> > >>print_r($result); > >> > = >>/*---------------------------------------------------------------------= -*/ > >> > >>The result currently looks like: > >> > >>Array > >>( > >> [0] =3D> 200 > >> [1] =3D> User Okay. > >>) > >> > >>But I need it like this: > >> > >>Array > >>( > >> [ret_code] =3D> 200 > >> [ret_message] =3D> User Okay. > >>) > >> > >>May I use "apachesoap:Map" for this? I found this in the nusoap = class=20 > >>source code. But is there some documentation for this? > >> > >>What changes are needed to let asociative arrays work with WSDL? > >> > >>Thanks a lot and best regards, > >> > >>Mario > >> > >> > >>------------------------------------------------------- > >>SF.Net email is sponsored by: Tell us your software development = plans! > >>Take this survey and enter to win a one-year sub to SourceForge.net > >>Plus IDC's 2005 look-ahead and a copy of this survey > >>Click here to start! = http://www.idcswdc.com/cgi-bin/survey?id=3D105hix > >>_______________________________________________ > >>Nusoap-general mailing list > >>Nus...@li... > >>https://lists.sourceforge.net/lists/listinfo/nusoap-general > >> > >=20 > >=20 > >=20 > > ------------------------------------------------------- > > SF.Net email is sponsored by: Tell us your software development = plans! > > Take this survey and enter to win a one-year sub to SourceForge.net > > Plus IDC's 2005 look-ahead and a copy of this survey > > Click here to start! = http://www.idcswdc.com/cgi-bin/survey?id=105hix > > _______________________________________________ > > Nusoap-general mailing list > > Nus...@li... > > https://lists.sourceforge.net/lists/listinfo/nusoap-general > |