QueueMetrics > Scripting QueueMetrics

How to use the XML-RPC with CF or Javascript

(1/2) > >>

seraph:
Hi guys,

Im a junior web developer working with ColdFusion8 and javascript. What Im trying to do for my company is replace the current wallboard monitor with my custom one with other information the call center agents need. The problem is that I cant seem to find any documentation for the XML-RPC implementation for ColdFusion or Javascript, so I have almost no idea on how to go about it. For now I managed to get the information from the wallboard using CFHTTP and stripping out what I need from it, but Im sure it would be alot less taxing if I use the XML-RPC to get only the information I require. What I've tried to do was first to get the specific table that I want from the queuemetrics-1.4.7/qm/qm_export_table.do?X.RealTimeDO.RTRiassunto address, but keeps telling me that my session is expired. I tried inputing the username and password in the CFHTTP tag but that didnt work. I then tried appending it to url as a url variable like queuemetrics-1.4.7/qm/qm_export_table.do?X.RealTimeDO.RTRiassunto&user="robot"&pass="something" but that still didnt work. I then tried to use javascript to get the XML, but that wasnt very successful as I could barely find any tutorials for using the xmlhttp.send() method properly. So  basically, could anybody help me out here? Ideally, I would really appreciate it if somebody could post a sample code of how to do this in either ColdFusion or Javascript, but even small things like pointing out if the url Im trying to get the data from is incorrect, whether I can login by appending the &user="robot"&password="something" to the url, or even what kind of method I would use to get the data like if I should use cfinvoke instead of cfhttp etc. Please help me, all comments are much appreciated.

Thanks.

QueueMetrics:
I came across this JavaScript library: http://code.google.com/p/json-xml-rpc/

I was able to port the sample script to it, it's pretty easy.


--- Code: ---<html>
<head>
<title>javascript_client.html</title>
<script src="rpc.js"></script>
</head>
<body>

<h1>QueueMetrics JavaScript XML-RPC example </h1>
<hr>

<script>
var server = "/DAILY/xmlrpc.do";

function run() {

        try {
             var service = new rpc.ServiceProxy( server, {
                        asynchronous:false,
                        protocol: "XML-RPC",
                        methods: ["QM.stats"]
  } );

res = service.QM.stats( "q1", "robot", "robot","", "",
"2005-10-10.10:23:12", "2009-10-10.10:23:10","",
[ "KoDO.DiscCauses", "CallDistrDO.AnsDistrPerDay" ]
);

                document.getElementById("RESULT").innerHTML = plotBlocks(res);

        } catch(e) {
                alert("Error raised: " + e);
        }

}


function plotBlocks( hmBlocks ) {

        s = "";

        for (var i in hmBlocks) {
                s += "<h2>Block: " + i + "</h2>";
                s += plotBlock( hmBlocks[i] );
        }

        return s;
}

function plotBlock( arBlock ) {
        s = "";
        for ( r =0; r < arBlock.length; r++ ) {
                s += "<tr>";
                for ( c = 0; c < arBlock[r].length; c++ ) {
                        s += "<td>" + arBlock[r][c] + "</td>";
                }
                s += "</tr>";
        }
        return "<table border=1>"  + s + "</table>";
}


</script>

<input type="button" value="Click me!" onclick="run();" >

<div id="RESULT"></div>

</body>
</html>


--- End code ---


This example requires the file rpc.js that comes from the client side
of the JSON-XML-RPC JavaScript library (see here: http://code.google.com/p/json-xml-rpc/ ).

Please note that the following file should be served on the same webserver as the QueueMetrics app it's going to access, or it will be denied access by the browser.

Please edit the file to set up access preferences.

We are going to include this example in QM as well.

seraph:
Thanks you soo much. I cant integrate it right now because the server running Queuemetrics is different to the one powering my custom wallboard, but my boss said he'll look at the code and try to do it on the Queuemetrics server.

Thanks Again!

torontob:
Hello,

I am trying the exact example and I am getting error:

Error raised: Error: Malformed XML document.

Has there been any major changes between the version this code was made for and the current 1.6.3.0 that I have installed right now?

Also, there is no port indication in the current Java file. How can a port 8099 for example be defined?

Thanks,


QueueMetrics:
You just need to point it to the QM instance.

Navigation

[0] Message Index

[#] Next page

Go to full version