As the wiki is still quite incomplete about this topic, here are some code snippets that might save others time researching what needs to be done. Mostly because it’s not always clear how things work in code. Most tips are around somewhere but these help you to get you started with your own server. It gives some more detail to the http://wiki.remobjects.com/wiki/Calling_RemObjects_SDK_Servers_from_JavaScript article, combined with a blog and connect topics.
class method TabellenAppServerMain.Main; var lServerChannel: ServerChannel; lMessage: Message; lJavaMessage: JavaScriptHttpDispatcher; // add this line begin Console.WriteLine('RemObjects SDK for .NET - Delphi Prism Command Line Server'); // autogenerated lServerChannel := new RemObjects.SDK.Server.ipHttpServerChannel();// autogenerated lMessage := new RemObjects.SDK.BinMessage(); // you need BOTH the JavaScript and BIN message items for communication (autgenerated) lJavaMessage := new JavaScriptHttpDispatcher(); lJavaMessage.Path := '/js/'; // might be default value lJavaMessage.Server := lServerChannel as IHttpServer; // you need this cast to this interface. // Do not use lServerChannel.Dispatchers.Add for the JavascriptHttpDispatcher, that will get you a runtime error with a casting problem. lServerChannel.Dispatchers.Add(lMessage.DefaultDispatcherName, lMessage); // -- Rest of file is autogenerated
file index.html
var Channel = new RemObjects.SDK.HTTPClientChannel("http://" + window.location.host + "/BIN"); var Message = new RemObjects.SDK.BinMessage(); var Service = new TabellenAppServerService(Channel, Message); function get_servertime() { Service.GetServerTime(
– rest of file autogenerated
You need to remotely get the RemObjectsSDK.js (or any other file) file, to overcome browser restrictions. The rest can be placed locally. But it might be good practice to get most of them from the server, so you can change them, and the third party only needs to manage a few files as possible.