I'm trying to retrieve data from Birst using WSDL. I generated the WSDL on Salesforce and got the Apex classses. Now I want to use a method called executeQueryInSpace that gets the token response from the login method (which I got successfully).
I'm keep getting the same error:
"Web service callout failed: WebService returned a SOAP Fault: getUserForToken: Login token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is invalid or has expired"
WS_Birst_wwwBirstCom birstInstance = new WS_Birst_wwwBirstCom(); WS_Birst_wwwBirstCom.CommandWebServiceSoap soapInstance = new WS_Birst_wwwBirstCom.CommandWebServiceSoap(); WS_Birst_wwwBirstCom.CommandQueryResult queryResults = new WS_Birst_wwwBirstCom.CommandQueryResult(); soapInstance.executeQueryInSpace(soapInstance.Login(username, ssopassword), query ,spaceId);
Birst answered to my case and they claim that I need to support Cookies Management, they also provided an example on C# but I'm not familiar with a similar option in Apex.
"Birst sessions are tied to the particular server in the load balancer pool and these are stored in Memory. So, very first time when a user does log in request, the load balancer generates a cookie and return it under response header named : Set-Cookie along with login Token response. So, Web services code needs to be programmed in such a way, so that all subsequent Web Service requests contains this Cookie value and ultimately it will help load balancer to take decision that next API call should be redirect to a particular server only. "
// get an instance of the web service CommandWebService cws = new CommandWebService(); // necessary to support cookie based load balancing cws.CookieContainer = new System.Net.CookieContainer(); // login to the web service string LoginToken = cws.Login(USERNAME, PASSWORD); // upload the file uploadData(cws, LoginToken, SPACE_ID, FILENAME);
Any thoughts how can I do something like that in Apex?