Reputation: 15886
I'm using SOAP through Visual Studio 2012 RC with C# to use the Magento API. I did this by adding a service reference pointing to the SOAP WSDL file.
Now, I'm having difficulties getting the shipping address of a SalesOrderEntity. Here's how I retrieve these entities.
var f = new filters();
f.filter = new associativeEntity[] {
new associativeEntity {
key ="status",
value ="processing"
}
};
var entities = mservice.salesOrderList(mlogin, f);
This works just great, but when I iterate through them and display some of their information, I stumble upon something strange.
foreach (var entity in entities)
{
//the following line crashes for some strange reason.
//the error is SoapHeaderException: Address not exists.
var info = mservice.customerAddressInfo(mlogin, int.Parse(entity.shipping_address_id));
Debug.WriteLine(info.firstname);
}
The shipping address is not 0
, has indeed been set to a proper number (and yes, it's a string for some weird reason although it always represents a number).
What am I doing wrong here?
Upvotes: 5
Views: 1471
Reputation: 866
The address is stored in a salesOrderAddressEntity
, which is inside the salesOrderEntity
.
var magento = new MagentoService();
var session = magento.login("LOGIN", "APIKEY");
var order = magento.salesOrderInfo(session, "100029631");
var address = order.shipping_address;
Console.WriteLine(address.firstname + " " + address.lastname);
Console.WriteLine(address.street);
Console.WriteLine(address.postcode + " " + address.city);
Upvotes: 5