Javascript : __namespace.SimpleLoginService is not a function

Hi,

(I’m trying DataAbstract)

I just generated my javascript library SDK with Service Builder. When I do this, I get a warning in service builder : “Used RODL for DataAbstract could not be loaded”.

Then, when load this in my JS client :

<script src="vendor/data-abstract/RemObjectsSDK.js" type="text/javascript"></script>
<script src="vendor/data-abstract/DataAbstract.js" type="text/javascript"></script>
<script src="vendor/data-abstract/DataAbstract4_intf.js" type="text/javascript"></script>
<script src="vendor/data-abstract/VCLApplication4.js" type="text/javascript"></script>

I get this error :

Uncaught TypeError: __namespace.SimpleLoginService is not a function

Hello

You need to re-add the Data Abstract RODL reference with correct path and then to regenerate the _Intf file.

Yes that’s what I did, still generates a js file full of “__namespace”.

I opened the Project Service Builder

I removed the DataAbstract RODL

I re-added the DataAbstract RODL

The path of the RODL I used is : $(Data Abstract for Delphi)\Source\DataAbstract4.rodl

I clicked on CodeGen - JavaScript - Generate RemObjects SDK for JavaScript Interface

I still got the warning “Code Generation” : “Used RODL for DataAbstract could not be loaded”.

This is the generated code :

//----------------------------------------------------------------------------//
// This unit was automatically generated by the RemObjects SDK after reading  //
// the RODL file associated with this project .                               //
//                                                                            //
// Do not modify this unit manually, or your changes will be lost when this   //
// unit is regenerated the next time you compile the project.                 //
//----------------------------------------------------------------------------//


/* This codegen depends on RemObjectsSDK.js
* Usage:
* var Channel = new RemObjects.SDK.HTTPClientChannel("http://localhost:8099/JSON");
* var Message = new RemObjects.SDK.JSONMessage();
* var Service = new NewService(Channel, Message);
* Service.Sum(1, 2,
*             function(result) {
*                 alert(result);
*             },
*             function(msg) {alert(msg.getErrorMessage())}
* );
*
*/

__namespace = this;
if ("VCLApplication4" != "") {
	var parts = "VCLApplication4".split(".");
	var current = this;
    for (var i = 0; i < parts.length; i++) {
		current[parts[i]] = current[parts[i]] || {};
		current = current[parts[i]];
    };
	__namespace = current;
};


// Struct: TTerm
__namespace.TTerm = function TTerm() {
    this.Beginning = {dataType : "DateTime", value : null};
    this.Ending = {dataType : "DateTime", value : null};
};
__namespace.TTerm.prototype = new RemObjects.SDK.ROStructType();
__namespace.TTerm.prototype.constructor = __namespace.TTerm;
RemObjects.SDK.RTTI["TTerm"] = __namespace.TTerm;




// Service: LoginService
__namespace.LoginService = function LoginService(__channel, __message, __service_name) {
  RemObjects.SDK.ROService.call(this, __channel, __message, __service_name);
  this.fServiceName = this.fServiceName || __service_name || "LoginService";
};

__namespace.LoginService.prototype = new __namespace.SimpleLoginService();


// Service: DataService
__namespace.DataService = function DataService(__channel, __message, __service_name) {
  RemObjects.SDK.ROService.call(this, __channel, __message, __service_name);
  this.fServiceName = this.fServiceName || __service_name || "DataService";
};

__namespace.DataService.prototype = new __namespace.DataAbstractService();


// Service: TermService
__namespace.TermService = function TermService(__channel, __message, __service_name) {
  RemObjects.SDK.ROService.call(this, __channel, __message, __service_name);
  this.fServiceName = this.fServiceName || __service_name || "TermService";
};


__namespace.TermService.prototype.ApplicationTerm = function(
	Term,
	__success, __error) {
    try {
        var msg = this.fMessage.clone();
        msg.initialize(this.fServiceName, "ApplicationTerm");
        msg.write("Term", "TTerm", Term);
        msg.finalize();
        this.fChannel.dispatch(msg, function (__message) {
		var __Term = __message.read("Term", "TTerm");
	        __success(
		__Term
		);
        }, __error);

    } catch (e) {
        __error(msg, e);
    };
};

__namespace.TermService.prototype.UserTerm = function(
	Term,
	__success, __error) {
    try {
        var msg = this.fMessage.clone();
        msg.initialize(this.fServiceName, "UserTerm");
        msg.write("Term", "TTerm", Term);
        msg.finalize();
        this.fChannel.dispatch(msg, function (__message) {
		var __Term = __message.read("Term", "TTerm");
	        __success(
		__Term
		);
        }, __error);

    } catch (e) {
        __error(msg, e);
    };
};

In my index.html file I have :

// R:/RemObjects SDK for JavaScript/Source/RemObjectsSDK.js
<script src="vendor/data-abstract/RemObjectsSDK.js" type="text/javascript"></script>
// R:/Data Abstract for JavaScript/Source/DataAbstract.js
<script src="vendor/data-abstract/DataAbstract.js" type="text/javascript"></script>
// R:/Data Abstract for JavaScript/Source/DataAbstract4_Intf.js
<script src="vendor/data-abstract/DataAbstract4_intf.js" type="text/javascript"></script>
// Generated code
<script src="vendor/data-abstract/VCLApplication4.js" type="text/javascript"></script>

Hello

Despite this warning message, does the regenerated code also throw with error message

?

Yes it does

Uncaught TypeError: __namespace.SimpleLoginService is not a function(anonymous function) @ VCLApplication4.js:54
VM85:1 POST http://localhost:8099/bin?1448983245762 500 (Internal Server Error)post @ VM85:1post @ VM85:1dispatch @ VM85:1__namespace.DataAbstractService.GetData @ VM90:1getData @ VM88:1(anonymous function) @ main.js:140invoke @ angular.js:4523extend.instance @ angular.js:9182nodeLinkFn @ angular.js:8299compositeLinkFn @ angular.js:7731compositeLinkFn @ angular.js:7734compositeLinkFn @ angular.js:7734publicLinkFn @ angular.js:7611(anonymous function) @ angular.js:1681Scope.$eval @ angular.js:16052Scope.$apply @ angular.js:16152bootstrapApply @ angular.js:1679invoke @ angular.js:4523doBootstrap @ angular.js:1677bootstrap @ angular.js:1697angularInit @ angular.js:1591(anonymous function) @ angular.js:29013fire @ jquery.js:3099self.fireWith @ jquery.js:3211jQuery.extend.ready @ jquery.js:3417completed @ jquery.js:3433

This is either due to the fact the the RODL did NOT import the DataAbstract RODL into the generated JS

or

That the generated paths should include RemObjects.DataAbstract.Server.SimpleLoginService instead of __namespace

That code line should look like

What’s interesting, the generated code file you posted earlier contains exactly this (correct) code line, but the error you get suggests that something else is being executed.

Whoops I’m sorry I posted my corrected version. I just updated the raw generated version

Does this corrected code work for you?

It does not throw error. But could the generator be fixed?

Thanks, logged as bugs://73782

Sure. I just logged the issue to fix it.

Sorry for the inconvenience

Thank you very much.