Still hoping for some input for this and I've made progress.
Question
How do you debug a Web Service in Web Ratio?
My Web Service uses a Custom Unit that will perform some business logic and then save a database record using code in the Custom Unit Service java class.
The Web Service is published because when I use a browser to point to the service a blank page is displayed (no error, but no results). Any slight error in the URI generates the appropriate Tomcat error, so the blank page is just an empty result of a correctly fired Web Service.
Furthermore, the javascript code (listed below) fires off correctly, and returns successfully for both methods. But as per the browser test, no results are provided. I have a System.out.println() in the Custom Unit java code, but this doesn't get written out to any Tomcat log files.
This is what I'm trying to achieve specifically the section describing the intention to fire some javascript (see ""processSingleOption()"" below) but I haven't been able to get it working.
NOTE: This is the solution using javascript where the other wiki help request is trying to use Links to fire off the MarkerResponse Custom Unit.
I have created a Web service within WebRatio as per Getting started with Web Services and I would like to invoke if from my Javascript in my Custom Unit style template.
The Web Service looks like this:
image?
The style unit creates a button to fire the javascript like this:
<input title=""<c:out value=""${<wr:UnitId/>.signInputLabel}""/>"" onclick=""processSingleOption<c:out value=""${<wr:UnitId/>.signInputLabel}""/>();"" type=""submit"" id=""button:<wr:Id context=""link""/>"" name=""button:<wr:Id context=""link""/>"" value=""<c:out value=""${<wr:UnitId/>.signName}""/>""""/>
The javascript processSingleOption() is as follows:
//
// Use AJAX to save the single option.
//
function processSingleOption<c:out value=""${<wr:UnitId/>.signInputLabel}""/>() {
try
{
var optionOid = <c:out value=""${<wr:UnitId/>.singleOptionOid}""/>;
var theURL = ""http://localhost:8080/Stigmergy/StigmergyService/StimgergyListener/saveContribution.do"";
theURL = theURL + ""?PositionIndex="" + <c:out value=""${<wr:UnitId/>.positionIndex}""/>;
theURL = theURL + ""&optionOid="" + optionOid;
theURL = theURL + ""&isRevoking="" + <c:out value=""${<wr:UnitId/>.revoking}""/>;
//alert (""Contribution '<c:out value=""${<wr:UnitId/>.signInputLabel}""/>' : "" + theURL );
// define the iteraction with the server -- true for as asynchronous.
req = getXMLHttpRequest();
req.onreadystatechange = handleHttpResponseSearch;
req.open(""GET"", theURL, true);
req.send(null);
}
catch(e)
{
alert(""There was an error saving. "" + e);
}
}
//
// If we have a valid login then validate the rest of the form
//
function handleHttpResponseSearch()
{
if (req.readyState == XMLHTTPREQUEST_READY_STATE_COMPLETED)
{
if (req.status == 200)
{
// Process the data.
//var jsonExpression = ""("" + req.responseText + "")"";
//var response = eval(jsonExpression);
alert(""Success:"" + req.responseText);
}
else
{
alert(""Error in response: HTTP ""
+ req.status
+ "" ""
+ req.statusText);
}
}
}