Username
Password
 
 

Join Our List ...

Enter your email address to receive product updates and annoucements.


News Feed ...

December 1, 2009
Version 5.0 released!

November 17, 2009
List automation added to support interactive autoresponders.

November 3, 2009
Magento catalog integrated into editor for easy building of product layouts.

October 27, 2009
Added order status mappings for Magento store owners to map customers to lists based on order statuses.

Hungry for more?
 Overview   |   Core Features   |   Add-on Modules   |   Price Calculator   |   30 Day Trial 
 

March 15, 2009 19:21 by Eric Hileman
.NET C# Object Library for Magento's XML-RPC API

We recently built a Magento connector for our Customer Management Module.  While building this connector we noticed a significant lack of information about how to work with the Magento API on the .NET platform.

Our first choice was to use the SOAP API because Visual Studio has wonderful support for SOAP.  However, after jumping through many hoops, the best we could do was add the Web Reference but after that it was unusable.  Apparently the SOAP API is not totally compliant with all the standards VS was hoping for. To go any further would have required hacking the core files and that was not an option for us to do as we could not possibly require all our clients start hacking their core files.  EDIT : As of v1.3 there is a second WSDL that reportedly has support for vs 2008.  Call it like so http://%3chost%3e/%3Cmagento%3E/api/v2_soap?wsdl

We then turned to the XML-RPC API and were able to start building out our object library.  We found that the documentation for the API was very poor and often wrong at times wrt to the type of values it was returning.  Almost everything goes in and out as strings which still baffles us.  The filter parameters that get passed in are not documentated anywhere that we could find so we pretty much just took educated guesses to find what we could.  Eventually we saw patterns in the inconsistencies, which were, at least, consistently inconsistent. 

Overall Magento really is a stellar eCommerce solution.  The checkout process is one of the finest we've ever seen.  So even though we really only needed to read the orders object, we went a head and built out the full object library with samples to every object and method.  We're making it publicly available here under the MIT X11 license.  We've used Charles Cook's XML-RPC.NET libary which is also published under the MIT X11 license.

We did need to modify Cook's library as the Magento XML-RPC API uses extensions for null values.  These values come back as <nil /> and will throw a nullreference exception.  We found two ways to handle this.  First is to search/replace the xml as it comes back.  The other is to catch the null reference exception when working with the properties.  In our testing the search/replace method was much more efficient but YMMV.

The source for our object library and samples is published here along with the source for Cook's XML-RPC.NET library that includes both hacks for the NULL values.

NOTES :

If you are receiving the error about calling parameters not matching signature then your problem is most likely eAccelerator.  We found that after disabling eAccelerator or adding a filter for the url "Api/*.php" the error goes away.  Apparently eAcclerator is causing a parameter validation exception to be thrown.  If eAccelerator has the API cached then the login call with throw error.  Otherwise you will be able to login but the second call with throw exception.  Subsequent calls with throw exception until eAcclerator releases it's cache.

If you are receving a "Not Found" error and you have multiple stores then you may need to pass the store id like this: http://www.mymagentostore/storedirectory/<storeid>/api/xmlrpc

 This library is now hosted over at google code.

Ez.Newsletter.MagentoApi - Release History

v1.1 : 2009-05-18
Ez.Newsletter.MagentoApi_v1.1.zip

  • Bug Fix : Product.Create sample not inserting product correctly.
  • Bug Fix : Order.Info not pulling full order information.
  • Bug Fix : ProductAttribute class missing members

v1.0 : 2009-03-15
Ez.Newsletter.MagentoApi_v1.0.zip



Actions: E-mail | Kick it! | Permalink | commentComments (12) | RSS comment feedComment RSS

Comments

Add comment


 

biuquote
  • Comment
  • Preview
Loading





 
   
Real Time Web Analytics