Skip to content

Commit ec2abda

Browse files
UPDATED: RQLConnector
1 parent 7ad239f commit ec2abda

2 files changed

Lines changed: 100 additions & 111 deletions

File tree

rqlconnector/RqlConnector.js

Lines changed: 83 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,106 @@
11
function RqlConnector(LoginGuid, SessionKey) {
2-
this.LoginGuid = LoginGuid;
3-
this.SessionKey = SessionKey;
4-
this.DCOM = 'DCOM';
5-
this.DCOMProxyUrl = 'rqlconnector/rqlaction.asp';
6-
this.WebService11 = 'WebService11';
7-
this.WebService11ProxyUrl = 'rqlconnector/rqlactionwebservice.aspx';
8-
this.WebService11Url = '/CMS/WebService/RqlWebService.svc';
9-
this.RqlConnectionType = '';
10-
this.InitializeConnectionType();
2+
this.LoginGuid = LoginGuid;
3+
this.SessionKey = SessionKey;
4+
this.DCOM = 'DCOM';
5+
this.DCOMProxyUrl = 'rqlconnector/rqlaction.asp';
6+
this.WebService11 = 'WebService11';
7+
this.WebService11ProxyUrl = 'rqlconnector/rqlactionwebservice.aspx';
8+
this.WebService11Url = '/CMS/WebService/RqlWebService.svc';
9+
this.RqlConnectionType = '';
10+
this.InitializeConnectionType();
1111
}
1212

13-
RqlConnector.prototype.SetConnectionType =function (ConnectionType)
14-
{
15-
this.RqlConnectionType = ConnectionType;
13+
RqlConnector.prototype.SetConnectionType = function (ConnectionType) {
14+
this.RqlConnectionType = ConnectionType;
1615
}
1716

18-
RqlConnector.prototype.GetConnectionType =function ()
19-
{
20-
return this.RqlConnectionType;
17+
RqlConnector.prototype.GetConnectionType = function () {
18+
return this.RqlConnectionType;
2119
}
2220

23-
RqlConnector.prototype.InitializeConnectionType =function ()
24-
{
25-
if(this.GetConnectionType() == '')
26-
{
27-
if(this.TestConnection(this.WebService11Url))
28-
{
29-
this.SetConnectionType(this.WebService11);
30-
}else{
31-
this.SetConnectionType(this.DCOM);
32-
}
33-
}
21+
RqlConnector.prototype.InitializeConnectionType = function () {
22+
if (this.GetConnectionType() == '') {
23+
if (this.TestConnection(this.WebService11Url)) {
24+
this.SetConnectionType(this.WebService11);
25+
} else {
26+
this.SetConnectionType(this.DCOM);
27+
}
28+
}
3429
}
3530

36-
RqlConnector.prototype.SendRql = function(InnerRQL, IsText, CallbackFunc)
37-
{
38-
switch(this.GetConnectionType())
39-
{
40-
case this.DCOM:
41-
this.SendRqlCOM(InnerRQL, IsText, CallbackFunc);
42-
break;
43-
case this.WebService11:
44-
this.SendRqlWebService(InnerRQL, IsText, CallbackFunc);
45-
break;
46-
}
31+
RqlConnector.prototype.SendRql = function (InnerRQL, IsText, CallbackFunc) {
32+
switch (this.GetConnectionType()) {
33+
case this.DCOM:
34+
this.SendRqlCOM(InnerRQL, IsText, CallbackFunc);
35+
break;
36+
case this.WebService11:
37+
this.SendRqlWebService(InnerRQL, IsText, CallbackFunc);
38+
break;
39+
}
4740
}
4841

49-
RqlConnector.prototype.SendRqlWebService = function(InnerRQL, IsText, CallbackFunc)
50-
{
51-
var SOAPMessage = '';
52-
SOAPMessage += '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">';
53-
SOAPMessage += '<s:Body><q1:Execute xmlns:q1="http://tempuri.org/RDCMSXMLServer/message/"><sParamA>' + this.padRQLXML(InnerRQL, IsText) + '</sParamA><sErrorA></sErrorA><sResultInfoA></sResultInfoA></q1:Execute></s:Body>';
54-
SOAPMessage += '</s:Envelope>';
55-
56-
$.post(this.WebService11ProxyUrl, { rqlxml: SOAPMessage, webserviceurl: this.WebService11Url },
57-
function(data){
58-
var RetRql = $(data).find('Result').text();
59-
60-
if(IsText)
61-
{
62-
data = RetRql;
63-
}
64-
else
65-
{
66-
data = $.parseXML( $.trim(RetRql) );
67-
}
68-
69-
CallbackFunc(data);
70-
});
42+
RqlConnector.prototype.SendRqlWebService = function (InnerRQL, IsText, CallbackFunc) {
43+
var SOAPMessage = '';
44+
SOAPMessage += '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">';
45+
SOAPMessage += '<s:Body><q1:Execute xmlns:q1="http://tempuri.org/RDCMSXMLServer/message/"><sParamA>' + this.padRQLXML(InnerRQL, IsText) + '</sParamA><sErrorA></sErrorA><sResultInfoA></sResultInfoA></q1:Execute></s:Body>';
46+
SOAPMessage += '</s:Envelope>';
47+
48+
$.post(this.WebService11ProxyUrl, {rqlxml: SOAPMessage, webserviceurl: this.WebService11Url},
49+
function (data) {
50+
var RetRql = $(data).find('Result').text();
51+
52+
if (IsText) {
53+
data = RetRql;
54+
}
55+
else {
56+
data = $.parseXML($.trim(RetRql));
57+
}
58+
59+
CallbackFunc(data);
60+
});
7161
}
7262

73-
RqlConnector.prototype.SendRqlCOM = function(InnerRQL, IsText, CallbackFunc)
74-
{
75-
var Rql = this.padRQLXML(InnerRQL, IsText);
76-
$.post(this.DCOMProxyUrl, { rqlxml: Rql }, function(data){
77-
if(IsText)
78-
{
79-
// do nothing
80-
}
81-
else
82-
{
83-
data = $('<div/>').append(data);
84-
}
85-
86-
CallbackFunc(data);
87-
});
63+
RqlConnector.prototype.SendRqlCOM = function (InnerRQL, IsText, CallbackFunc) {
64+
var Rql = this.padRQLXML(InnerRQL, IsText);
65+
$.post(this.DCOMProxyUrl, {rqlxml: Rql}, function (data) {
66+
if (IsText) {
67+
// do nothing
68+
}
69+
else {
70+
data = $($.trim(data));
71+
}
72+
73+
CallbackFunc(data);
74+
});
8875
}
8976

90-
RqlConnector.prototype.padRQLXML =function (InnerRQL, IsText)
91-
{
92-
var Rql = '<IODATA loginguid="' + this.LoginGuid + '" sessionkey="' + this.SessionKey + '"';
93-
if(IsText)
94-
{
95-
Rql += ' format="1"';
96-
}
97-
98-
Rql += '>' + InnerRQL + '</IODATA>';
99-
100-
if(this.GetConnectionType(this.WebService11) == this.WebService11)
101-
{
102-
Rql = '<![CDATA[' + Rql + ']]>';
103-
}
104-
105-
return Rql;
77+
RqlConnector.prototype.padRQLXML = function (InnerRQL, IsText) {
78+
var Rql = '<IODATA loginguid="' + this.LoginGuid + '" sessionkey="' + this.SessionKey + '"';
79+
if (IsText) {
80+
Rql += ' format="1"';
81+
}
82+
83+
Rql += '>' + InnerRQL + '</IODATA>';
84+
85+
if (this.GetConnectionType(this.WebService11) == this.WebService11) {
86+
Rql = '<![CDATA[' + Rql + ']]>';
87+
}
88+
89+
return Rql;
10690
}
10791

108-
RqlConnector.prototype.TestConnection =function (Url)
109-
{
110-
var Isvalid = false;
92+
RqlConnector.prototype.TestConnection = function (Url) {
93+
var Isvalid = false;
11194
$.ajax({
11295
async: false,
11396
url: Url,
114-
success: function(){
115-
Isvalid = true;
97+
success: function () {
98+
Isvalid = true;
11699
},
117-
error: function(){
118-
Isvalid = false;
119-
}
100+
error: function () {
101+
Isvalid = false;
102+
}
120103
});
121-
122-
return Isvalid;
104+
105+
return Isvalid;
123106
}

rqlconnector/rqlaction.asp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<%
2-
'Response.ContentType = "text/xml"
2+
Response.ContentType = "text/xml; charset=utf-8";
3+
4+
Session.Timeout = 180
5+
Server.ScriptTimeout = 180
36
47
Dim objIO 'Declare the objects
58
Dim xmlData, sError, retXml
6-
set objIO = Server.CreateObject("RDCMSASP.RdPageData")
7-
objIO.XmlServerClassName = "RDCMSServer.XmlServer"
89
9-
xmlData = Request.Form("rqlxml")
10-
11-
xmlData = objIO.ServerExecuteXml (xmlData, sError)
10+
On Error Resume Next
11+
Set objIO = Server.CreateObject("RDCMSASP.RdPageData")
12+
objIO.XmlServerClassName = "RDCMSServer.XmlServer"
13+
If Err.Number <> 0 Then
14+
Set objIO = Server.CreateObject("OTWSMS.AspLayer.PageData")
15+
End If
1216
17+
xmlData = Request.Form("rqlxml")
18+
xmlData = objIO.ServerExecuteXml (xmlData, sError)
1319
Set objIO = Nothing
14-
20+
1521
If xmlData = "" Then
16-
retXml = "<ERRORTEXT>" & sError & "</ERRORTEXT>"
22+
retXml = "<ERRORTEXT>" & sError & "</ERRORTEXT>"
1723
Else
18-
retXml = xmlData
24+
retXml = xmlData
1925
End If
20-
26+
2127
Response.Write(retXml)
22-
%>
28+
%>

0 commit comments

Comments
 (0)