Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Question on calling a service from RTC WebUI

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 com.test.app.ui.web.ui.internal.page.pageTest 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: com.test.app.ui.web.ui.internal.page.pageTest.js 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.

-------------------

dojo.provide("com.test.app.ui.web.ui.internal.page.pageTest");

dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("net.jazz.ajax.ui.PlatformUI");
dojo.require("com.ibm.team.repository.web.transport.ServiceRequest");
dojo.require("com.ibm.team.repository.web.transport.ServiceResponseHandler");
dojo.require("com.ibm.team.repository.web.transport.TeamServerClient");


(function(){

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

dojo.declare("com.test.app.ui.web.ui.internal.page.pageTest", [dijit._Widget, dijit._Templated], {
templateString: "<div><div dojoAttachPoint='hiJazzAttachPoint'>uninitialized</div></div>",

postCreate: function(){
var ActionRegistry = PlatformUI.getWorkbench().getActionRegistry();
ActionRegistry.registerAction("com.test.app.ui.web.testAction", this, "testAction");
},

testAction: function(){

var ServiceRequest = com.ibm.team.repository.web.transport.ServiceRequest;
var ServiceResponseHandler = com.ibm.team.repository.web.transport.ServiceResponseHandler;
var TeamServerClient = com.ibm.team.repository.web.transport.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);


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

})();

1

0 votes


Accepted answer

Permanent link
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 https://jazz.net/wiki/bin/view/Main/JazzAjaxTransportDesign.

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

1 vote

Comments

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
sounds like one of your 'requires' is not available.


0 votes

Comments

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

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

var self= this;
var handlerObject= {
success: function(resultList) {
self._displayResults(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 


com.ibm.team.repository.web.transport.ServiceRequest._validateMethod=function(_13){ 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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941
× 24

Question asked: Aug 07 '12, 9:08 a.m.

Question was seen: 6,847 times

Last updated: Aug 09 '12, 10:52 a.m.

Confirmation Cancel Confirm