It's all about the answers!

Ask a question

Question on calling a service from RTC WebUI

Serghei Zagorinyak (482913) | asked Aug 07 '12, 9:08 a.m.
retagged Aug 09 '12, 10:52 a.m. by Vladimir Amelin (70472226)

Hi! I'm new to Jazz and RTC and have faced a task of creating a simple plugin.

I have a service plugin providing com.example.hellojazz.common.service.IHelloJazzService (took it from this tutorial)

and a web page from here.

When I run the page with contents from the tutorial, it works fine. But when I add some code to call my service, I get Resource does not exist: exception. The page is in the same place, of cource. Below is the code of the page, bold is the one I added (from here, listing 6-8).

I'll be grateful for any help on this problem.





var PlatformUI = net.jazz.ajax.ui.PlatformUI;
var hiCount = 0;

dojo.declare("", [dijit._Widget, dijit._Templated], {
templateString: "<div><div dojoAttachPoint='hiJazzAttachPoint'>uninitialized</div></div>",

postCreate: function(){
var ActionRegistry = PlatformUI.getWorkbench().getActionRegistry();
ActionRegistry.registerAction("", this, "testAction");

testAction: function(){

var ServiceRequest =;
var ServiceResponseHandler =;
var TeamServerClient =;

var handler = {
_success: function(done){

console.log("success + done);

_failure: function(done){
  console.log("failure + done);

var srh = new ServiceResponseHandler(handler, "_success", "_failure");

var reqParms= {

param1: value1,
param2: value2,

var serviceRequest =
new ServiceRequest("com.example.hellojazz.common.service.IHelloJazzService",
"test",reqParms );

var cback = TeamServerClient.invokeService(serviceRequest, srh);

this.hiJazzAttachPoint.appendChild(document.createTextNode("Hi from Jazz!!! (" + hiJazz + ")"));


Accepted answer

permanent link
John Vasta (2.6k15) | answered Aug 07 '12, 11:27 a.m.
The Hello Jazz tutorial illustrates the implementation of an RPC-style service, which can only be invoked by Java clients, not Javascript clients. A service that can be invoked by Javascript clients is known as a "modelled REST" service, and the mechanism is described in

To convert the Hello Jazz service to be a modelled REST service, I think you'll need to do this:

  1. Change the IHelloJazzService interface to extend the ITeamModelledRestService interface
  2. Change the service method name from "sayHello" to something like "getHelloMessage" (must start with "get")
  3. In the component extension declaration, change the service type from RPC to MODELLED_REST
  4. Change your Javascript code to use "getHelloMessage" as the method name
Serghei Zagorinyak selected this answer as the correct answer

Serghei Zagorinyak commented Aug 08 '12, 2:39 a.m.

Thanks a lot. Now the thing seems to work fine! =) Still have to deal with a lot of JS code, so more questions coming.

2 other answers

permanent link
sam detweiler (12.5k6195201) | answered Aug 07 '12, 10:17 a.m.
sounds like one of your 'requires' is not available.

Serghei Zagorinyak commented Aug 07 '12, 10:25 a.m. | edited Aug 07 '12, 10:43 a.m.

No, that's not likely. I've edited the service invocation code a bit and the page began to load. Still doesn't work the right way, though. There were no changes in the "requires" section. Looks like the first problem was in requesting a wrong method from the service interface.

permanent link
Serghei Zagorinyak (482913) | answered Aug 07 '12, 10:20 a.m.
edited Aug 07 '12, 10:23 a.m.

I've altered the service invocation code to look like this:

var self= this;
var handlerObject= {
success: function(resultList) {
failure: function(errorObj) {
self.handleError(errorObj,"Error getting remote data.");
var responseHandler= new ServiceResponseHandler(handlerObject, "success", "failure");
var reqParms= {

var serviceRequest =
new ServiceRequest("com.example.hellojazz.common.service.IHelloJazzService",
"sayHello",reqParms ); var cback = TeamServerClient.invokeService(serviceRequest, srh);

 Now the page loads, but I get a JavaScript error: TypeError: _13.match(_14) is null which comes from{ if(!dojo.isString(_13)){ return false; } var _14=/^(get|post)/; var _15=_13.match(_14)[0]; return _15!==null; };

and actually says nothing to me except that something is wrong with my service request.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.