Hey guys,
I just want to share my discovery !
I had big problems getting my Visual Studio to import the WebService WSDL https://api.e-conomic.com/secure/api1/economicwebservice.asmx?wsdl
And first of all, the internal importer does not seems to support SOAP12 as required here (Tried with https://api.e-conomic.com/secure/api1/economicwebservice.asmx?wsdl /protocol:SOAP12)
So grab the WSDL.EXE there is supplied with you Visual Studio, and specify the protocol to SOAP12. Then it will generate the EconomicWebService.cs just fine.
My second finding was the initial load took 40-45 seconds. And it seems the WSDL was downloaded behind the scenes every time.
So I found a way to eliminate that, by Settings > Build > Changing Generate Serialization Assembly from Auto to On.
Screendump -> http://imgur.com/6Y7nLb0
After that, it just to a split second to do the initial object creation
I also got problems initiating the object, got a cookie exception, and was missing some cookie stuff.
So my class is ended up like this :
private static EconomicWebService EconomicClient
{
get
{
if (HttpContext.Current.Application["EconomicWebService"] == null)
{
EconomicWebService client = new EconomicWebService { CookieContainer = new CookieContainer() };
client.ConnectWithToken("Token1","Token2");
HttpContext.Current.Application["EconomicWebService"] = client;
}
return (EconomicWebService)HttpContext.Current.Application["EconomicWebService"];
}
}
And then it's easy to create cashbook entries
public static CashBookEntryHandle CreateCashbookEntry(int account, int contraAccount, decimal amount, string description, DateTime date)
{
var cashbook = EconomicClient.CashBook_FindByNumber(1);
CashBookEntryData cashBookEntryData = new CashBookEntryData
{
AccountHandle = EconomicClient.Account_FindByNumber(account),
Type = CashBookEntryType.FinanceVoucher,
Amount = amount,
Date = DateTime.Now,
Text = description,
CurrencyHandle = EconomicClient.Currency_FindByCode("DKK"),
AmountDefaultCurrency = amount,
ContraAccountHandle = EconomicClient.Account_FindByNumber(contraAccount),
CashBookHandle = cashbook,
VatAccountHandle = EconomicClient.VatAccount_FindByVatCode("U25"),
ContraVatAccountHandle = EconomicClient.VatAccount_FindByVatCode("U25")
};
return EconomicClient.CashBookEntry_CreateFromData(cashBookEntryData);
}
Enjoy !
/Jan