Magento Forum

   
[DataFlow with Webservices] How to call a Magento-API Function in C# using SOAP
 
CKoewing
Jr. Member
 
Total Posts:  9
Joined:  2009-04-29
 

Hi MagCommunity,

i’m trying to develop a SOAP-Client for Magento using C#.
With the Magento-WSDL-File and the WSDL.exe from VS08 i have created the proxy-class.
Now i can connect (login/logout) to my magento-demo-shop, but the call-function i can’t start.

For example, when i call the customer.create-Funktion (*.Call("customer.create", args)), in csharp i must set an Object-Array (new object[] { ??? } ), in php it’s an associative Array. In magento-wsdl the type is set as ‘xsd:anytype’ :/

In C# there is not realy a associative Array, i tried hashtable, dictionary and Array in Array ( new object[]{ new object[]{"firstname", “first"}, ... } ). So which type should i take, or is there another magento-wsdl with the data-objects?

PS: i don’t want to use rpc-xml^^

Here are some snippets:

using (MagentoConnect magCon = new MagentoConnect(url))
{
  string sessionId 
magCon.Login(userpass);

  if (
magCon.IsLogged)
  
{
    Customer newCustomer 
= new Customer();
    
newCustomer.firstname "first";
    
newCustomer.lastname "last";
    
newCustomer.email "new@customer.com";

    
int customerId Customer.Create(magConnewCustomer);    
  
}
}

public static int Create(MagentoConnect magConCustomer customer)
{
    object[] args 
Extensions.ObjectPropertiesToObjectArray(customer); // => new object[]{ new object[]{"firstname", "first"}, ... };
    
return Convert.ToInt32(magCon.Call("customer.create"args));
}

Thanks & Greets,
raddde

 
Magento Community Magento Community
Magento Community
Magento Community
 
CKoewing
Jr. Member
 
Total Posts:  9
Joined:  2009-04-29
 

update push

 
Magento Community Magento Community
Magento Community
Magento Community
 
CKoewing
Jr. Member
 
Total Posts:  9
Joined:  2009-04-29
 

Now i have the answer:

Use the SOAP V2!!!

URL: http://<host>/<magento>/api/v2_soap?wsdl

Damn i haved searched while, but now it works.

There is an example in the attachment.

have fun.

@thE_iNviNciblE: BiG ThX!1 wink

greets,
raddde

File Attachments
MagentoConnectionLibrary.zip  (File Size: 53KB - Downloads: 255)
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top