1

I’m trying to program Magento from c#. In the first step I added Service Reference to project in Visual Studio. But I don’t have MagentoService Class. I have it when I download wdsl file and convert it by wsdl.exe from Visual Studio Command Line. So, in the case with service reference, my code looks like this:

MagentoSer.Mage_Api_Model_Server_HandlerPortTypeClient client = new MagentoSer.Mage_Api_Model_Server_HandlerPortTypeClient();
var session= client.login("id", "password");
client.call(session, "catalog_category.tree", null);
client.endSession(session);

everything works all right. But when I’m trying to use

MagentoSer.Mage_Api_Model_Server_HandlerPortTypeClient client = new MagentoSer.Mage_Api_Model_Server_HandlerPortTypeClient();
var session= client.login("id", "password");
client.call(session, "product_stock.list", "qqaz");
client.endSession(session);

Exception occurs “Error in deserializing body of reply message for operation ‘call’” The specified type was not recognized: name=’Map’, namespace=’http://xml.apache.org/xml-soap’, at ."}

When testing from PHP everything works ok. I have found this two articles http://codeblow.com/questions/php-web-service-in-c-invoke-function-returns-null/ PHP Web Service in C# : Invoke() function returns null but I can’t catch the big picture.

Are those about object args in

public object call(string sessionId, string resourcePath, object args);

or about output from function? And one more thing. When searching the Web I have found example of code (Magneto help) where strange arrays are used (like complexFilter). How Can I get them if I connect to wsdl file via Visual Studio? Is this in Magento Administrator rights to expose them to me?

Best Regards

Przemysław Staniszewski

Community
  • 1
  • 1
  • that looks like soap v1 from magento, if you have possibility, use soap v2 api in magento, it is much better for usage from c#. If not, I have some code, that works with v1. – Giedrius Oct 17 '12 at 11:52

1 Answers1

0

In Magento admin panel try to switch on the WSI Compliance mode.

vsushkov
  • 2,445
  • 1
  • 19
  • 28
  • Thank You very much. Please, tell me is there any more action need to take by Administrator after change WS-I setting? Or after Enable it should generate tags with wsdl: and xsd: just like that? Is there any cache to remove or something? Best Regards – Przemysław Staniszewski Oct 17 '12 at 14:22
  • I have something new after change. I can't login. The maximum nametable character count quota (16384) has been exceeded while reading XML data. The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota. This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader. – Przemysław Staniszewski Oct 22 '12 at 13:59
  • I cannot help you here because I'm not a C# programmer :) – vsushkov Oct 22 '12 at 14:52
  • Ok, I found thread http://stackoverflow.com/questions/7996931/c-sharp-soap-error-in-deserializing-body-of-reply-message-magento-api. It's security reason - section of app.config on my (client) site. It's needs only change in it's values. – Przemysław Staniszewski Oct 23 '12 at 06:42
  • But second line client.call(session, "product_stock.list", "qqaz"); still not working. Unknown error. – Przemysław Staniszewski Oct 23 '12 at 06:59
  • According to http://www.magentocommerce.com/api/soap/introduction.html, there is no 'product_stock.list' method. – vsushkov Oct 23 '12 at 08:26
  • I have tested var b = proxy.call(sesja, "catalog_product.info", "mycomputer"); and all works fine with soap 1. But if I try var d = proxy.call(sesja, "product.list", "mycomputer"); there is problem. Error appears in function with filters as second argument. How should I pass them? String[] not working with SOAP 1. – Przemysław Staniszewski Oct 23 '12 at 10:45
  • Maybe I should pass them as XML (filters I mean)? – Przemysław Staniszewski Oct 23 '12 at 10:46
  • Ok. 1. The solution is WS-I mode 2. Using soap 2 wsdl file 3. not using .call function but approach like this http://stackoverflow.com/questions/8938835/products-up-and-download-with-c-sharp-and-the-magentostore 4. For every error with login or function: read error details and change values in app.config So, yes switch on the WSI Compliance mode was the part of the solution. Best Regards – Przemysław Staniszewski Oct 23 '12 at 11:57