#1 2022-05-22 02:40:35

Cahaya
Member
Registered: 2015-06-21
Posts: 36

Sample - 14 Interface-based SOA Javascript Client

Dear AB,

function registerSoa(){ //access mORMot SOA
  let xhr = new XMLHttpRequest();
  let url = new URL("http://localhost:888/root/Calculator._contract_");
  signature = sessionSignature();
  url.searchParams.set("session_signature",signature);
  xhr.onload = function() {
    if (xhr.status == 200){ 
      let hasil = xhr.response;
      console.log(hasil.result[0]);
      runSoa();
    };  
  };
  xhr.open('POST', url);
  xhr.responseType = 'json';
  xhr.send();
};

Calculator._contract_ return a number. What number is it ? Do I need to use it before call Calculator.Add ?
So far I just ignore it, and send the next step, server response it.

Tq

Offline

#2 2022-06-28 08:01:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Sample - 14 Interface-based SOA Javascript Client

This is the "contract" of the interface, i.e. the hash of all methods and parameters.
It allows to ensure that the interface is the same on both client and server side, so that you can e.g. use a JSON array of unnamed parameters as input/output instead of a JSON object of named parameters.

Just search for the documentation about it.

Offline

Board footer

Powered by FluxBB