Tuesday, January 28, 2014

RESTful WebService: Overview

RESTful WS tech stack

HTTP + JSON


JSON Syntax

reserved: {}  []  \  :  " ,        0-9 e E + -
structure:  name value pair, where name is "string" and value can be string, number, object, array
string:  "(^[" | control_Char])" 
number:  [+-] [0-9]+[.][0-9]* [[eE] [+-]][0-9]+
object:  {}
array:   []

An example

Request                                                            
POST https://mytire.com/cws/Cws.svc/rest/Login HTTP/1.1 
Host: mytire.com 
Content-Type: application/json; charset=UTF-8 
Content-Length: 145 
CostarApplicationId: MyTireCompany 
CostarGuid: C19F0CAC-75F4-EB74-46EF-78C37524467F 
CostarSignature: r9jqorXwl88qPL6kxWdU/kKHLwJLsLWtwdvv2+efuLU= 
CostarSigningAlgorithm: HMAC-SHA256 
CostarUtc: 2013-06-05T19:54:36.470 
CostarCipher: AES256 
CostarCipheredFieldCsv: p_Password 
CostarCipherIv: qjcdVTwYWn379KHrPqxoVA== 

{
"p_Company" : "weborder"
, "p_LoginName" : "MyUserName"
, "p_Password" : "I+7MqdYJ+VJYC2LYDTMnaQ=="
, "p_IsLogoutMySessions" : "false"
, "p_NewPassword" : ""
}


Response                                                            
HTTP/1.1 200 OK 
Content-Length: 314 
Content-Type: application/json 
Server: Microsoft-HTTPAPI/2.0 
Access-Control-Allow-Origin: * 
Date: Thu, 07 Nov 2013 23:33:32 GMT 

{
"DbVersion": "3.0.0.461"
, "CwsVersion": "4.1.61.2"
, "IsAdministrator": false
, "PasswordExpiryUtc": "9999-12-31T00:00:00"
, "Result": "VALID"
, "SessionExpiryUtc": "2013-02-01T20:13:24.977"
, "SessionGuid": "15b4b64d-8a6c-e211-9195-005056930637"
, "UnifiedBuildNumber": "4.1.61.2"
}

No comments: