API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Visual Studio and WSDL import problems and extremely slow initial session load

+1
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.
 
 
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
created Oct 8, 2015 by janhjordie
0% Accept Rate

edited Oct 12, 2015 by olej
Q 1 A 2 C 0

1 Answer

0
Thank you for sharing Jan!
answered Oct 12, 2015 by olej
Visma e-conomic A/S
...