restweb-servicesaxis2cstaff-wsf

Axis2C Staff REST login service


I'm using Axis2/C unofficial with the Staff project to simply expone a set of methods to return a dataset with the REST paradigm.

Now I need to authenticate users and I want to use the "staff.Login" built in service of Staff, always in REST methods.

I am able to call the "login" and "openSession" methods (they both return me a valid sessionID), but I cannot mantain this session on following calls because if I afterwards call the method "getUserName" it says i'm a guest user and not the user i authenticated before!

Do I have to pass the session ID on every following call to the service like a token? Can someone link me any documentation or example about the login service? (I can't find much on the net)

Thanks.

PS: Staff has a sample client for testing this service, and it runs correctly, but I need to use the service from a browser with REST methods.


Solution

  • When using REST+JSON, your request could be like that:

    {
      "@headers": {
        "SessionId":"SID"
      },
      "GetUserName": {}
    }
    

    If you're using REST+SOAP, your request could be like this:

    <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
      <soapenv:Header>
        <sid:SessionId xmlns:sid="http://tempui.org/staff/sessionid">SID</sid:SessionId>
      </soapenv:Header>
      <soapenv:Body>
        <ns0:GetUserName xmlns:ns0="http://tempui.org/staff.Login"/>
      </soapenv:Body>
    </soapenv:Envelope>
    

    Where SID is a session ID returned by "openSession" or "login".