2B9A75E094B1481CA4C981324462D53F
  • Internet
  • 28.02.2018
  • EN

Simply RedDot: "Evolution of RQL and Management Server Plugins"

written by Jian Huang, 9. May 2013
 

In the Beginning

There was COM using VB, but susceptible to server timeout in large operations and cannot cancel the server side operation once it has started.

Set objIO = CreateObject("RDCMSASP.RdPageData")
objIO.XmlServerClassName = "RDCMSServer.XmlServer"
xmlData = "<IODATA sessionkey=""" & session("sessionkey") & """ loginguid=""" & session("loginguid") & """><PAGE action=""load"" guid=""" & strTreeGuid & """/></IODATA>"
xmlData = objIO.ServerExecuteXml (xmlData, sError)
' parse that xmlData

 

Shortly After

There was COM using C#. It is a cleaner language, but one has to relax COM security for this to work. Also, it is susceptible to server timeout in large operations and cannot cancel the server side operation once it has started.

// look up how to transfer asp session to aspx session
// Basically, asp page loop through all sessions and submit them to aspx
// which then save the received sessions into aspx sessions
string _LoginGuid = HttpContext.Current.Session["projectguid"].ToString();
string _SessionKey = HttpContext.Current.Session["sessionkey"].ToString();
string _PageGuid = HttpContext.Current.Session["treeguid"].ToString();
object objRQL;
 
object[] RQL_Server = { "RDCMSServer.XmlServer" };
objRQL.GetType().InvokeMember("XmlServerClassName", BindingFlags.SetProperty, null, objRQL, RQL_Server);
object[] RQL_Command = { string.Format("<IODATA sessionkey=\"{0}\" loginguid=\"{1}\"><PAGE action=\"load\" guid=\"{2}\"/></IODATA>", _LoginGuid, _SessionKey, _PageGuid) };
object retObj = objRQL.GetType().InvokeMember("ServerExecuteXml", BindingFlags.InvokeMethod, null, objRQL, RQL_Command);
 
if (retObj != null)
{
    // parse that retObj
}

 

Not Long After

There was web service using C#. It has the benefit of a cleaner language and no need for extra configuration in COM security, but the plugin will be competing with Management Server for communication bandwidth because many core components are also using the web service. Also, it is susceptible to server timeout in large operations and cannot cancel the server side operation once it has started.

// look up how to transfer asp session to aspx session
// Basically, asp page loop through all sessions and submit them to aspx
// which then save the received sessions into aspx sessions
string _LoginGuid = HttpContext.Current.Session["projectguid"].ToString();
string _SessionKey = HttpContext.Current.Session["sessionkey"].ToString();
string _PageGuid = HttpContext.Current.Session["treeguid"].ToString();
 
// RqlService is a class manually generated using Visual Stuio by pointing to the web service URL
RqlService RqlServiceObj = new RqlService();
 
string RQL_Command = string.Format("<IODATA sessionkey=\"{0}\" loginguid=\"{1}\"><PAGE action=\"load\" guid=\"{2}\"/></IODATA>", _LoginGuid, _SessionKey, _PageGuid);
object retObj = RqlServiceObj.ExecuteString(RQL_Command);
 
if (retObj != null)
{
    // parse that retObj
}

 

Overtime

Some people advanced to AJAX against an ASP connector or the web service because these plugins are easy to write, troubleshoot, and no longer susceptible to server timeout in large operations and run away server side operation once it has started. It is best practice to use ASP connector instead of web service because ASP connector do not compete with core component for communication bandwidth and it is compatible with Management Server 6.x, 7.x, 9.x, 10.x, whereas the web service is only available beginning at 7.x, changes location at 10.x and 11.x. Hence plugins written against the web service is not all version compatible automatically.

// AJAX ASP
var strRQLXML = padRQLXML('<PAGE action="load" guid="<%= session("treeguid") %>">');
 
$.post('rqlaction.asp', { rqlxml: strRQLXML },
function(data){
    // parse $(data)
});
 
function padRQLXML(innerRQLXML)
{
    return '<IODATA loginguid="<%= session("loginguid") %>" sessionkey="<%= session("sessionkey") %>">' + innerRQLXML + '</IODATA>';
}
<?xml version="1.0" encoding="utf-8" ?>
<%
    ' action.asp
    Response.ContentType = "text/xml"
 
    Dim objIO   'Declare the objects
    Dim xmlData, sError, retXml
    set objIO = Server.CreateObject("RDCMSASP.RdPageData")
    objIO.XmlServerClassName = "RDCMSServer.XmlServer"
 
    xmlData = Request.Form("rqlxml")
 
    xmlData = objIO.ServerExecuteXml (xmlData, sError) 
 
    Set objIO = Nothing
 
    If sError <> "" Then
        retXml = "<ERROR>" & sError & "</ERROR>"
    Else
        retXml = xmlData
    End If
 
    Response.Write(retXml)
%>
// AJAX web service
var SOAPMessage = '';
SOAPMessage += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cms="http://reddot.de/cms/webservices/navigation/1_1"><soapenv:Header/><soapenv:Body><cms:ExecuteString><cms:command>';
SOAPMessage += padRQLXML(InnerRQL);
SOAPMessage += '</cms:command></cms:ExecuteString></soapenv:Body></soapenv:Envelope>';
 
$.ajax({
    type: 'POST',
    url: '/CMS/Navigation/Services/RQLService.asmx',
    data: SOAPMessage,
    contentType: 'text/xml; charset=utf-8',
    dataType: 'xml',
    beforeSend: function(xhr) {
        xhr.setRequestHeader('SOAPAction', '"http://reddot.de/cms/webservices/navigation/1_1/ExecuteString"');
    },
    success: function (data) {
        // parse $(data)
    },
    error: function (message) {
        //alert(message);
    }
});
 
function padRQLXML(InnerRQL)
{
    var Rql = '<IODATA loginguid="<%= session("loginguid") %>" sessionkey="<%= session("sessionkey") %>"><![CDATA[' + InnerRQL + ']]></IODATA>';
 
    return Rql;
}

 

Finally

Management Server is at version 11.x. One has to change the COM object name in ASP in order for VB plugins to continue to work, and this should only be a short term fix because as stated in the RQL manual, COM will be obsolete and web service will be the sole future. One also has to change the web service URL and SOAP format in order for AJAX web service plugins to continue to work in 11.x. The question: how to write a plugin that is 7.x to 11.x compatible automatically? Answer: use a AJAX RQL connector library at https://github.com/solutionexchange/j-rql-connector-https

<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="Rqlconnector.js"></script>
<script type="text/javascript">
var LoginGuid = '<%= session("loginguid") %>';
var SessionKey = '<%= session("sessionkey") %>';
var RqlConnectorObj = new RqlConnector(LoginGuid, SessionKey);
 
var strRQLXML = '<PAGE action="load" guid="' + PageGuid + '"/>';
RqlConnectorObj.SendRql(strRQLXML, false, function(data){
    // parse $(data)
});
</script>
' quick and short term change to make VB to continue to work
Set objIO = CreateObject("OTWSMS.AspLayer.PageData")
xmlData = "<IODATA sessionkey=""" & session("sessionkey") & """ loginguid=""" & session("loginguid") & """><PAGE action=""load"" guid=""" & strTreeGuid & """/></IODATA>"
xmlData = objIO.ServerExecuteXml (xmlData, sError)
' parse that xmlData

 

Note

The AJAX RQL Connector is meant to be used on something small to medium things, like to automatically send some RQLs whenever a user does something in SmartEdit or Page Preview, or to send some RQLs based on user inputs in a plugin interface. Ideally, all plugins should use this connector library over other RQL libraries (Java, C#, PHP?) because a plugin should be plug-and-play with no dependency on any other external installations or configurations.

Does it mean other RQL libraries (Java, C#, PHP?) are bad? No. They are still useful for large implementations, where a plugin should really be called an application integration. However, please be aware that support for RQL libraries (Java, C#, PHP?) falls outside of OpenText support because in event of error, one has to proof the fault is at RQL level, not the library that encapsulates the RQL.


Source: Evolution of RQL and Management Server Plugins

© copyright 2013 by Jian Huang