Debugging ScriptX.Services
Thoughts on debugging ScriptX.Services
If only code were perfect, each written line worked exactly as required and the whole worked too. These are thoughts on where to look to resolve problems, not necessarily on how to look.
Of course, the problem may reside in the ScriptX.Services implementation. We fix all reported problems as soon as is practical and all licensees are entitled to full support via email.
If you are having problems, contact us and our development team will respond.
Own code
All APIs return errors with an appropriate HTTP error (typically 500) and a text description in the response.
Using the browser developer tools and network monitoring will show the response from the server, this should give a good clue on the problem.
Note that all calls to ScriptX.Services for Cloud and for Windows PC must include a valid license identity in the authentication header of the http request. For ScriptX.Services On Premise the header is not required and any value given will be ignored as in this case it is the ScriptX.Services installation itself that is licensed.
Using the Client libraries
The ScriptX.Services Client Library provides a set of singleton instances to work with the ScriptX.Services API. The hierarchy implements useful behaviour to interact with the API at increasing levels of abstraction from the API.
The goal of the library is to bring an emulation of MeadCo's ScriptX.Add-on to working with MeadCo ScriptX.Services and this emulation is included in the library.
However, higher levels of the library can be used as convenience wrappers and functions to your own code.
Using ScriptX.Add on emulation
We strongly recommended that when using ScriptX.Addon emulation the MeadCoScriptXJS Library is also used as this provides a number of useful features for obscuring the inevitable differences there are between the implementations of ScriptX.Add-on and ScriptX.Services. The emulation of the .Addon API with ScriptX.Services is excellent, but not perfect.
Tips
-
Check the developer console
Many development issues are logged to the developer console rather than reported as errors to the user.
If “nothing appears to happen” check the developer console for messages, warnings and errors.
-
Enable verbose logging
By default the library does not log informational messages to the console. These can be enabled by including the following code after referencing the library:
<script src="//cdn.jsdelivr.net/npm/scriptxprint-html@1/dist/meadco-scriptxservices.min.js"></script> <script type="text/javascript"> // If ScriptX.Services client libraries have been loaded enable // some more verbose logging to developer console (f12) for debugging purposes if (typeof MeadCo === "object") { MeadCo.logEnabled = true; } </script>
The above will provide detailed logging of library actions for printing etc. - in otherwords after the libraries have initialised. To obtain logging of the library initialisation from the get-go (for example, to discover issues with licensing errors) logging can be enabled before the library is referenced:
<script type="text/javascript"> var MeadCo = { "logEnable": true }; </script> <script src="//cdn.jsdelivr.net/npm/scriptxprint-html@1/dist/meadco-scriptxservices.min.js"></script>
-
Use latest versions
Check that the latest versions of all components are being used - ScriptX.Services and any javascript libraries being used.
-
Order of implementation is important
When working on pages that should support IE 11 and evergreen browsers, the preference should be that ScriptX.Addon is used when IE 11 is the browser.
The ScriptX.Addon objects should be written in the html for the page before the
<script></script>
references to the ScriptX.Services libraries.In IE 11, the libraries will then see that ScriptX.Addon is available and will not interfere with its use. For evergreen browsers, ScriptX.Addon will not be found and the libraries will provide the emulation.
-
Order of scripts is important
If you are creating your own minimised package or are referencing each file individually, please note that the order of files is critical:
<script src="meadco-core.js"></script> <script src="meadco-scriptxprint.js"></script> <script src="meadco-scriptxprinthtml.js"></script> <script src="meadco-scriptxprintpdf.js"></script> <script src="meadco-scriptxfactory.js"></script> <script src="meadco-scriptxprintlicensing.js"></script> <script src="meadco-secmgr.js"></script>
Bad ordering of files or failure to include a required file will result in errors such as:
"MeadCo.ScriptX.Print.PDF is not available to ScriptX.Services factory emulation."
-
Verify license deployment details
Double check the correct license GUID is being used. When using ScriptX.Services for Windows PC also verify that the path to the license file is either “warehouse” or the fullly qualified path to the license file.
When coding a page for use by both ScriptX.Addon and ScriptX.Services ensure that both reference the correct license.
Review License deployment.
-
Verify use of libraries
-
A library should only be referenced once, for example:
<script src="//cdn.jsdelivr.net/npm/scriptxprint-html@1/dist/meadco-scriptxservices.min.js"></script>
-
Do not include minimized and unminimized versions of files.
-
Do not include multiple packages, for example do not include meadco-scriptxservices.min.js and meadco-scriptxservicesprint.min.js
-
-
Use network logging
The libraries can eat/translate errors in a way that obscures the underlying problem.
Using the browser developer tools and network monitoring will show the response from the server, this should give a good clue on the problem.
If you find such a problem, contact us and our development team will look into improving behaviour.
-
Review bare bones exemplar code
A set of quick samples are deliberately bare bones and simple and are intended as exemplars of the scripting required to get ScriptX.Services working.
The examples illustrate many common advanced features working with both ScriptX.Addon and ScriptX.Services for Windows PC from exactly the same script code with and without the use of MeadCoScriptXJS Library .