Re: [SOAP] Generic Database Access
| From: | Bill Moran | Date: | Fri, 01 Aug 2003 21:39:20 +0000 |
| Subject: | Re: [SOAP] Generic Database Access | ||
| References: | 1 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-914@lists.php.net to get a copy of this message | ||
Rob Booth wrote:
Has anyone tried this yet? I'm wondering how I would go about building a Web Service that would allow me to run a query against my database and get back a result set. I don't really want to get by every row/col wrapped in SOAP because this overhead would be unwieldly. Is there a more elegant solution that I'm just not seeing? I was thinking that I could build my own return structure and wrap it in a single SOAP tag then parse the structure to re-build the row/col structure on the client side, but this also seems wrong.Yeah. It makes me wonder why you'd use soap at all?
Any thoughts or ideas are more than welcome.If you want to keep the platform/application independence that soap is supposed to offer, you should probably stick with soap variables for all your database rows. If the overhead seems to much, consider looking at ODBC.
So in example I'd like to be able to send this, or any other, query to my database: SELECT name, address1, address2, city, state, zip FROM users And get back my results, but not in a huge SOAP structure like the one below (only 1 row shown) <Result xsi:type="ns4:QueryResult">I'll be more than happy to accept correction if I'm wrong, but isn't this the drawback to soap? I mean, not every protocol is cut out for every type of data transfer. Besides, I think the idea of a soap rpc is to abstract it more than you are doing: i.e. the soap client shouldn't care if there's a database, flat file or a hashtable on the server end. However, everyone has different needs, and not all systems fit all needs. Perhaps you could make a single string value in the soap return values that contained a comman (or other) seperated list. While that's not 100% cross-platform portable, it's a close as you can easily get without adding a lot of overhead. You could also include a soap structure that contained the number of fields/rows and the data type of each column. This would make it easier to parse the string. -- Bill Moran Potential Technologies http://www.potentialtech.com<Rows xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[100]"SOAP-ENC:offset="[0]"><item xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[6]"SOAP-ENC:offset="[0]"><item xsi:type="xsd:string">Rob</item> <item xsi:type="xsd:string">1234 Main St.</item> <item xsi:type="xsd:string">Suite 123</item> <item xsi:type="xsd:string">AnyTown</item> <item xsi:type="xsd:string">AnyState</item> <item xsi:type="xsd:string">92837</item> </item>As you can see this would get to be very large with only a few rows, imagine it with thousands of rows. So I'm hoping that there is an easier/nicer way to return unknown data from a database using a Web Service.