I would like to know (a sample code if it is not too much to ask for) how to talk to Magento 2's SOAP API from C# using Webservice (not service reference). With Magento 1.x versions I used something like
static MagentoWebService.MagentoService MyService = new MagentoWebService.MagentoService();
static string Login = MyService.login(Config.Login, Config.Password);
where as login being,
public string login(string username, string apiKey)
{
object[] results = this.Invoke("login", new object[] {
username,
apiKey});
return ((string)(results[0]));
}
How do I do the same/similar one with Magento 2. I have seen few example given in PHP. However, I am struggling to convert that in to C# or understand properly. Could someone please help with this.
So far in my new code I tried this:
catalogProductRepositoryV1Service productservice = new catalogProductRepositoryV1Service();
CatalogProductRepositoryV1GetResponse response = new CatalogProductRepositoryV1GetResponse();
CatalogProductRepositoryV1GetRequest request = new CatalogProductRepositoryV1GetRequest();
request.sku = "WJ01";
response = productservice.catalogProductRepositoryV1Get(request);
Console.WriteLine(response.result.id.ToString());
But it wont work, since I haven't logged in to the SOAP service yet.
Best Answer
I was able to make requests to Magento 2 web API using the following example in 2014 (before 2.0 release), but it should work now as well.
To run it, follow the steps:
http://<magento.host>/soap/default?wsdl&services=customerCustomerAccountServiceV1
namespace toMagentoService
C# console application example:
This example uses Service reference (not Webservice), but still might be helpful to understand how to pass authentication headers.