Topic
  • 2 replies
  • Latest Post - ‏2012-08-16T14:40:53Z by venkatakrishnarao
SystemAdmin
SystemAdmin
570 Posts

Pinned topic How to invoke webservice via worklight, which needs authentication information

‏2012-05-07T03:01:37Z |
Hi,
I am trying to invoke webservices offered by sharepoint with http adapter. But when I tried to invoke the worklight procedure, the result always complains the request is unauthorized like:

{
"errors": [
"Premature end of file.",
"Failed to parse the payload from backend (procedure: HttpRequest)"
],
"info": [],
"isSuccessful": false,
"statusCode": 401,
"statusReason": "
Unauthorized
",
"warnings": []
}

It seems that I should offer some authentication information. But how? Anybody could offer resolution? Thanks!
  • AntonAleksandrov
    AntonAleksandrov
    22 Posts

    Re: How to invoke webservice via worklight, which needs authentication information

    ‏2012-05-08T08:07:58Z  
    According to response your back end web service requires authentication.
    You can use "headers" property in your parameters to specify the credentials back end requires.
    See page 123 of http://www.worklight.com/assets/docs/Worklight%204.2.1%20Developer%20Reference%20Guide.pdf
  • venkatakrishnarao
    venkatakrishnarao
    7 Posts

    Re: How to invoke webservice via worklight, which needs authentication information

    ‏2012-08-16T14:40:53Z  
    Hi,
    Here the service you are trying to invoke is having login credentials. So you have to use username token tag inside the SOAP request header like

    <wsse:UsernameToken wsu:Id="UsernameToken-4" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsse:Username>+user+</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">+pwd+</wsse:Password>
    </wsse:UsernameToken></wsse:Security>

    user and pwd are credentials we are passing to the procedure.