0

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);

Edit:

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.

Their Answer:

"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. "

Example (C#):

// 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?

4
  • 2
    Sounds like Birst issue, have you contacted their support? Feb 20, 2018 at 2:14
  • Yes, I'm waiting for their response Feb 20, 2018 at 7:15
  • I'm voting to close this question as off-topic because it sounds primarily like an issue with a third party, rather than with Salesforce.
    – Derek F
    Feb 20, 2018 at 14:46
  • Edited the question, may you open it again? Feb 20, 2018 at 15:20

1 Answer 1

0

I figured it out.

The login request returns a token as a response but in addition, it puts a pair in a Header map as follow:

Map<String, String> outputHttpHeaders_x = new Map<String, String>();
outputHttpHeaders_x.put('Set-Cookie', 'value');

Therefore, when one wants to use one of the methods generated by the WSDL he should put into the inputHttpHeaders_x map the value of the 'Set-Cookie' key with a key name 'Cookie' as follow:

Map<String, String> inputHttpHeaders_x= new Map<String, String>();
inputHttpHeaders_x.put('Cookie', outputHttpHeaders_x.get('Set-Cookie'));

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .