Skip to main content

WEBfactory 2010

Using the web services via HTTP requests

Abstract

This article provides all the needed information to learn and understand how to use web services via HTTP requests.

The WEBfactory 2010 WCF web services can be used programatically (from a C# environment, for example) but can also be accessed using HTTP requests from a HTML application. Take a look below to see how a web service method can be called via HTTP.

Login example

The WEBfactory 2010 WCF SecurityService Documentation lists the Login method as follows:

Login(string sessionId, Guid clientId, string userName, string password, bool isDomainUser, int millisecondsTimeOut)

This method follows the WEBfactory 2010 Security Protocol.

Syntax

Login(string sessionId, Guid clientId, string userName, string password, bool isDomainUser, int millisecondsTimeOut);

Description

Tries to perform a user login against WEBfactory 2010 server or ActiveDirectory. The login will be done in one single operation. If login fails, an exception will be thrown.

Parameters

  • sessionId (string) - the unique ID of the session, returned by the connect() method

  • clientId (string) - the user defined unique ID of the client from which the web service is called

  • userName (string) - the name of the WEBfactory 2010 defined user in context of which the method is called

  • password (string) - the user password

  • isDomainUser (bool) - true if the WEBfactory 2010 defined user is an Active Directory user

  • millisecondsTimeOut (int) - the amount of time, in milliseconds, in which the authentication process is verified. If this time period is exceeded or the login failed, a fault exception will be generated.

Return Value

A security token which can be used in all subsequent secured operations

HTTP request for the Login method

Using the above information, the HTTP request can be constructed as follows:

Request URL

http://[computer name or IP]/_SERVICES/WebServices/WCF/SecurityService.svc/js/Login

The URL is created using the HTTP endpoint and the method name:

  • endpoint: http://[computer name or IP]/_SERVICES/WebServices/WCF/SecurityService.svc/js

  • method name: Login

Request Method

POST

Request Payload

{
    "sessionId": "5c1dea15-2516-4836-a1b0-b7bf6769cf31",
    "clientId": "94e87366-c0ac-407d-b61a-3a5a4a5eec06",
    "userName": "webfactory",
    "password": "webfactory",
    "isDomainUser": false,
    "millisecondsTimeOut": 10000
}

The same parameters as listed in the method documentation are sent as payload for the POST request.

Response

{
    "d": "H4sIAAAAAAAEAAXB22JDMAAA0A/y0NWkeNhD3BOteyS8oaC7FAA=="
}

The request will return the security token if the log in was successful. This security token can be further used in all security methods. If the login fails, an empty string will be returned.

LogoutByToken example

After a successful login, any other security related actions, like logging out, can be called using the security token returned by the Login method. The WEBfactory 2010 WCF SecurityService Documentation lists the LogoutByToken method as follows:

Syntax

LogoutByToken(string securityToken, int millisecondsTimeOut);

Description

Logs out the currently logged in user using the security token

Parameters

  • securityToken (string) - the security token returned by the Login() method

  • millisecondsTimeOut (int) - the amount of time, in milliseconds, in which the authentication process is verified. If this time period is exceeded or the login failed, a fault exception will be generated.

Return Value

A true or false depending on the success of the logout operation

HTTP request for the LogoutByToken method

Using the above information, the HTTP request can be constructed as follows:

Request URL

http://[computer name or IP]/_SERVICES/WebServices/WCF/SecurityService.svc/js/LogoutByToken

The URL is created using the HTTP endpoint and the method name:

  • endpoint: http://[computer name or IP]/_SERVICES/WebServices/WCF/SecurityService.svc/js

  • method name: LogoutByToken

Request Method

POST

Request Payload

{
    "securityToken": "H4sIAAAAAAAEAAXB22JDMAAA0A/y0NWkeNhD3BOteyS8oaC7FAA==",
    "millisecondsTimeOut": 10000
}

The same parameters as listed in the method documentation are sent as payload for the POST request. The securityToken is returned by the Login method.

Response

{
    "d": true
}

The request will return a boolean value, as described in the method documentation.

IsUserLoggedIn example

Another useful request could be for checking if a user is logged in. The WEBfactory 2010 WCF SecurityService Documentation lists the IsUserLoggedIn method as follows:

Syntax

IsUserLoggedIn(string securityToken, int millisecondsTimeOut);

Description

Checks if the current user is still logged in

Parameters

  • securityToken (string) - the security token returned by the Login() method

  • millisecondsTimeOut (int) - the amount of time, in milliseconds, in which the authentication process is verified. If this time period is exceeded or the login failed, a fault exception will be generated.

Return Value

True if the current user (identified by the security token) is still logged in; otherwise, false.

HTTP request for the IsUserLoggedIn method

Using the above information, the HTTP request can be constructed as follows:

Request URL

http://[computer name or IP]/_SERVICES/WebServices/WCF/SecurityService.svc/js/IsUserLoggedIn

The URL is created using the HTTP endpoint and the method name:

  • endpoint: http://[computer name or IP]/_SERVICES/WebServices/WCF/SecurityService.svc/js

  • method name: IsUserLoggedIn

Request Method

POST

Request Payload

{
    "securityToken": "H4sIAAAAAAAEAAXB22JDMAAA0A/y0NWkeNhD3BOteyS8oaC7FAA==",
    "millisecondsTimeOut": 10000
}

The same parameters as listed in the method documentation are sent as payload for the POST request. The securityToken is returned by the Login method.

Response

{
    "d": true
}

The request will return a boolean value, as described in the method documentation.