C# magento soap v2 api

Last modified by jdurand on Fri, June 25, 2010 10:03
Source|Old Revisions  

This is an old revision of the document!


If your like me you’ve been tasked with integrating the magento online system with legacy order fullfillment and accounting software in the back office. This guide serves to help anyone looking to use visual studio 2008 to program a c# application for ushering data in and out of magento. This guide is meant for version though it may work with other versions. It should also be noted that I am using the .net framework version 3.5 though i’m not sure that’s relevant.

Making a connection

The first thing you need to do is log into magento and create a user and give him/her permission to query the api. System→Web Services

remember you api key because you will use it in the following steps.

Open up visual studio and create a new project. Mine was windows forms based. Under solution explorer right click and choose Add Service Reference when the dialog comes up click advanced. Next click Add Web Reference enter in the path to your wsdl file. and example would be


click Go

You should now see “MagentoService” Description with a bunch of methods underneath.

set the web reference name in this case it would be com.exampledomain.www

Click Add Reference

You should now have a reference in the solution explorer. In order to use this in you project you simple need to put a

using com.exampledomain.com

You will then have access to the MagentoService object. This will be your primary object for interacting with magento. The following code serves to illustrate how you would use the MagentoService class.

           String mlogin = mservice.login("YOUR_USERNAME", "YOUR_API_KEY");
          filters mf = new filters();
           complexFilter[] cpf = new complexFilter[1];
           complexFilter mcpf = new complexFilter();
           mcpf.key = "increment_id";
           associativeEntity mas = new associativeEntity();
           mas.key = "gt";
           mas.value = "1008001";
           mcpf.value = mas;
           cpf[0] = mcpf;
           mf.complex_filter = cpf;
          salesOrderEntity[] soe = mservice.salesOrderList(mlogin, mf);
          if (soe.Length > 0)
              foreach (salesOrderEntity msoe in soe)
                      Debug.WriteLine("" + msoe.billing_firstname + " " + msoe.subtotal);
                  catch (Exception merror)
                      MessageBox.Show("" + msoe.order_id + ""+merror.ToString());


This code gets you all of the orders that are greater than a specified ordernumber and then iterates through each printing the billing firstname and the subtotal to the debugger.

The rest is up to you.