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

How do you get result from e-conomic web service

0

Hey there, 

I have a small UI which returns result from SOAP web service. I used that with the E-conomic web service just to see what result I get back. The method I call is Connect passing 3 arguments:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:e="http://e-conomic.com">
   <soapenv:Header/>
   <soapenv:Body>
      <e:Connect>
         <e:agreementNumber>12345678</e:agreementNumber>
         <e:userName>myUsername</e:userName>
         <e:password>password1</e:password>
      </e:Connect>
 </soapenv:Body>
</soapenv:Envelope>
 
This will give me a string back like this:
<ConnectResponse xmlns="http://e-conomic.com">
         <ConnectResult>ulv4iy2maks2tfub8bcqa255</ConnectResult>
</ConnectResponse>
 
which I guess it is fine (successfully logged in). Then I want to call another method from e-conomic like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:e="http://e-conomic.com">
   <soapenv:Header/>
   <soapenv:Body>
      <e:Employee_GetAll/>
   </soapenv:Body>
</soapenv:Envelope>
 
but then of course this will not work as I have not send user credentials, resulting in the following error:
 <faultstring>Economic.Api.Exceptions.AuthenticationException(E02250): Not logged in - could not resolve authenticationContext (id=6b19287e-e411-48a3-9e3b-1539cbcaebe7)</faultstring>
 
So the question is how do I get data back from the web service methods? 
I have to do all this in VBA code from Excel. 
 
created Nov 3, 2014 by pepyss
50% Accept Rate
Q 2 A 0 C 2

1 Answer

0

You need to set your session Id in your request header to the response from the login.
I have no idea how to do that in VBA but maybe you can do it through the soap header?

          <soapenv:Header>
                <xog:Auth><xog:SessionID>yourConnnnectionResultHere</xog:SessionID></xog:Auth>
          </soapenv:Header>
 
Or something similar. (I am not too versed in SOAP)
answered Nov 4, 2014 by Teyken
Thanks for the answer.
Nothing helped though. I tried the following:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:e="http://e-conomic.com">
   <soapenv:Header>
       <xog:Auth>
       <xog:SessionID>amxuekusz2a3kwviagf3hnfy</xog:SessionID>
       </xog:Auth>
  </soapenv:Header>
   <soapenv:Body>
      <e:Employee_GetAll/>
   </soapenv:Body>
</soapenv:Envelope>

to get all employees but instead I get Economic.Api.Exceptions.ServerException
I am pretty sure xog: is not the correct namespace, that was just an example.

In c# I use a cookie to set the sessionId, I have no idea how you would do that in VBA.

I looked it up on the homepage and it seems you need to use the cookie:

From http://e-conomic.github.io/eco-api-sdk-ref-docs/

Connecting to SOAP

Different languages and framework will have their own functionality for connecting to a SOAP based web service. Most of these involves automatically generating client code based on the WSDL, but it is also possible to build the XML envelopes completely by hand. You must ensure that the ASPNet session cookie is passed along in all requests, some frameworks will do this automatically, but not all.
Visma e-conomic A/S
...