views:

700

answers:

3

I am trying to call a PHP Magento store web service from C#.

How do I create this type of an "ARRAY KEY" in C# to pass to PHP:

call( $sessionId, 'product_stock.update', array('Sku', array('qty'=>50, 'is_in_stock'=>1)) );

Here is a link to the magento wiki for the call:

http://www.magentocommerce.com/wiki/doc/webservices-api/api/cataloginventory_stock_item#cataloginventory_stock_item.update

Thanks for the help in advance!

GBY,

-R

+1  A: 

It is a bit simplier than you thought.

This function: $proxy->call($sessionId, 'product_stock.update', array('Sku', array('qty'=>50, 'is_in_stock'=>1)));

passes XML using format specified in following documents:

http://www.w3.org/TR/soap11/

http://www.w3.org/TR/soap12/

http://www.w3.org/TR/wsdl/

And it is really possible that format of XML looks like:

<xml> <element>Sku</element> <element>...</element> </xml>

So treat these weird arrays as datasource for XML

Mr.ElectroNick
Thnanks for the reply, what I am looking for is how to pass this data from C#, I have tried string arrays, object arrays and even hashtable and sorted lists...not sure what else to use to simulate the ARRAY KEY in PHP when I pass the data...GBY,-R
+2  A: 

We had a heck of a time working with the API in C#, mainly due to the lack of examples. Eventually we got it all figured out and built out an entire object library for .net that includes all the objects and methods of the API. It also includes examples for every object and method.

We published our library under the MIT X11 license and you can read more about it and download the source here:

.NET C# Object Library for Magento’s XML-RPC API

A: 

i've played pretty hard with the magento api using soap (product create) and I couldn't get it to work with the XMLRPC or SOAP out of the box.

What i did was using XAMPP setup a basic Product.Create call using PHP and got it to save the Envelope.

Then I took this envelope into .NET and recreated it with an XML/HTTP Post.

I couldn't find any Generic Objects that would let me create the structure like the PHP Associative array. The only one that would probably represent it would be an Old HashTable with some of the subkeys containing HashTables as their value in a tree structure.

Paul Farry