Professional Documents
Culture Documents
A2 From SOAP To REST
A2 From SOAP To REST
Arnaud Bouchez
June 2015
From SOAP to REST
SOAP
REST
JSON
Security
practice
WSDL
Defines
Processing model
Extensibility model
Underlying protocol binding
Message construct
Feature complete
Time proof
Feature complete
Time proof
Severalimplementations (1.0/1.1/WCF/J2EE)
Verbose and heavy (slow)
Complex
as HTTP/1.1
{"Customer":
As JSON {"ID":1234, "Name":"Dupond", "Address":"Tree street"}}
{"Customer":
As JSON {"ID":1234, "Name":"Dupond", "Address":"Tree street"}}
Open
XML
Any complex (even custom) types
SOAP standard
Binary (CDATA)
Validation (XSDL)
Binary
BSON
MessagePack
Protocol Buffers
WCF
Authentication
Authorization
Testing
Transmission encryption
Single sign-on
TSQLRestServer TSQLRestClient
TSQLRest
TSQLRestServer
TSQLRest
TSQLRestClientURIMessage
TSQLHttpClientGeneric
Implementing a method
procedure TSQLRestServerTest.Sum(Ctxt: TSQLRestServerURIContext);
begin
with Ctxt do
Results([Input['a']+Input['b']]);
end;
Implementing a method
procedure TSQLRestServerTest.Sum(Ctxt: TSQLRestServerURIContext);
begin
Ctxt.Results([Ctxt['a']+Ctxt['b']]);
end;
TSQLRestServerURIContext
TSQLRestServerURIContext = class
protected
...
function URIDecodeREST: boolean; virtual;
procedure URIDecodeSOAByMethod; virtual;
procedure URIDecodeSOAByInterface; virtual; abstract;
function Authenticate: boolean; virtual;
procedure ExecuteSOAByMethod; virtual;
procedure ExecuteSOAByInterface; virtual; abstract;
procedure ExecuteORMGet; virtual;
procedure ExecuteORMWrite; virtual;
...
TSQLRestServerURIContext
TSQLRestServerAuthenticationSignedURI TSQLRestServerAuthenticationNone
TSQLRestServerAuthenticationURI
TSQLRestServerAuthentication
ID : integer
Data : TSQLRawBlob
DisplayName : RawUTF8
ID : integer
GroupRights : TSQLAuthGroup AuthGroup
AccessRights : RawUTF8
LogonName : RawUTF8
Ident : RawUTF8
PasswordHashHexa : RawUTF8
SessionTimeout : integer
V1 := _Json('{"name":"John","year":1982}');
V2 := _Json('{name:"John",doc:["one",1,"two",2.5]}');
var V: variant;
...
V := _Json('{arr:[1,2]}');
writeln(V._Count); // will write 1 (one property in the V object)
V.arr.Add(3); // will work, since V.arr is returned by reference (varByRef)
writeln(V); // will write '{"arr":[1,2,3]}'
V.arr.Delete(1);
writeln(V); // will write '{"arr":[1,3]}‘
SynMongoDB.pas