Work item calculated values using SOA call
5 answers
Hi to everyone:
I have a Remedy service (http://10.51.242.52/WsCAP-R/wsConParadigmRemedy.asmx?WSDL) where there are 6 operations, I´m only want to use one operation where I send a Remedy number and receive a detail of that Remedy number, I have created to new attributes to the defect work item, one the number and the other the description, inside the dojo script I extract the number from the defect work item to send that to the service, at this time I´m stuck to create the request for the service, this is the code:
dojo.provide("com.acme.providers.script.DetalleIncidenteScripted");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojox.xml.parser");
(function()
{
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var StrNumeroIncidente = "0";//get number value
var StrProveedor = "XXXXXXX";
var StrPwd = "XXXXXXXX";
var scriptname = "DetalleIncidenteScripted";
var StrDetalle = new String("No se encontro detalle del Numero de Incidente. Favor de revisar el numero del incidente.");
var StrServiceURL = "http://10.51.242.52/WsCAP-R/wsConParadigmRemedy.asmx?WSDL"; //service to invoke
dojo.declare("com.acme.providers.script.DetalleIncidenteScripted", null,
{
getValue: function(attribute, workItem, configuration)
{
console.log(scriptname + " - Inicio js DetalleIncidenteScripted");
StrNumeroIncidente = workItem.getValue("numeroIncidenteRemedy");
console.log(scriptname + " Numero de Incidente Remedy: " + StrNumeroIncidente);
if(StrNumeroIncidente==null || StrNumeroIncidente=="0") //validate the Remedy number
{
console.log(scriptname + " Numero incidente vacio");
return StrDetalle;
}
else
{
console.log(scriptname + " Iniciando llamada a webservice");
var soapMessage = new String(); // this is where I create the request with all the parameters
if(window.XMLHttpRequest)//I don´t know if this will work, this is where I´m stuck
{
httpRequest=new XMLHttpRequest();
} else if (window.ActiveXObject)
{
httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.open("POST",url,true);
if (httpRequest.overrideMimeType)
{
httpRequest.overrideMimeType("text/xml");
}
httpRequest.onreadystatechange=populateResponse;
httpRequest.setRequestHeader("Man", url + " HTTP/1.1")
httpRequest.setRequestHeader("MessageType", "CALL");
httpRequest.setRequestHeader("Content-Type", "text/xml");
httpRequest.send(soapMessage);
valTimeout=setTimeout("timeout(httpRequest);",120000);
return service.DetalleReporte.callService("DetalleReporte", StrNumeroIncidente, StrProveedor, StrPwd);//this is the call to the service, DetalleReporte is the operation that I will use
}
}
});
})();
I hope you can help me with this.
Regards
I have a Remedy service (http://10.51.242.52/WsCAP-R/wsConParadigmRemedy.asmx?WSDL) where there are 6 operations, I´m only want to use one operation where I send a Remedy number and receive a detail of that Remedy number, I have created to new attributes to the defect work item, one the number and the other the description, inside the dojo script I extract the number from the defect work item to send that to the service, at this time I´m stuck to create the request for the service, this is the code:
dojo.provide("com.acme.providers.script.DetalleIncidenteScripted");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojox.xml.parser");
(function()
{
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var StrNumeroIncidente = "0";//get number value
var StrProveedor = "XXXXXXX";
var StrPwd = "XXXXXXXX";
var scriptname = "DetalleIncidenteScripted";
var StrDetalle = new String("No se encontro detalle del Numero de Incidente. Favor de revisar el numero del incidente.");
var StrServiceURL = "http://10.51.242.52/WsCAP-R/wsConParadigmRemedy.asmx?WSDL"; //service to invoke
dojo.declare("com.acme.providers.script.DetalleIncidenteScripted", null,
{
getValue: function(attribute, workItem, configuration)
{
console.log(scriptname + " - Inicio js DetalleIncidenteScripted");
StrNumeroIncidente = workItem.getValue("numeroIncidenteRemedy");
console.log(scriptname + " Numero de Incidente Remedy: " + StrNumeroIncidente);
if(StrNumeroIncidente==null || StrNumeroIncidente=="0") //validate the Remedy number
{
console.log(scriptname + " Numero incidente vacio");
return StrDetalle;
}
else
{
console.log(scriptname + " Iniciando llamada a webservice");
var soapMessage = new String(); // this is where I create the request with all the parameters
if(window.XMLHttpRequest)//I don´t know if this will work, this is where I´m stuck
{
httpRequest=new XMLHttpRequest();
} else if (window.ActiveXObject)
{
httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.open("POST",url,true);
if (httpRequest.overrideMimeType)
{
httpRequest.overrideMimeType("text/xml");
}
httpRequest.onreadystatechange=populateResponse;
httpRequest.setRequestHeader("Man", url + " HTTP/1.1")
httpRequest.setRequestHeader("MessageType", "CALL");
httpRequest.setRequestHeader("Content-Type", "text/xml");
httpRequest.send(soapMessage);
valTimeout=setTimeout("timeout(httpRequest);",120000);
return service.DetalleReporte.callService("DetalleReporte", StrNumeroIncidente, StrProveedor, StrPwd);//this is the call to the service, DetalleReporte is the operation that I will use
}
}
});
})();
I hope you can help me with this.
Regards
I checked with a member of the Tracking and Planning team and this was his response:
I don't believe it is possible. The assumption is that our script providers are sync operations which return the result directly. There is no way in JavaScript to block on a service call. What will happen is that you make the call and then continue execution and return null. When the service call returns with a value there will be no one listening to pick up that value.
You will likely need to follow Ralph's links and look at doing this via a server-side Java contribution.
Comments
Millard Ellingsworth
FORUM ADMINISTRATOR / JAZZ DEVELOPER Sep 27 '13, 12:53 p.m.Hi, Miguel. Can you please provide some more details? Perhaps an example? All I can do is guess at the moment: it sounds like you want to call an (external?) web service from the JavaScript attribute customization of a work item.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 30 '13, 8:08 a.m.This blog post describes how to use the HTTP filtered value provider to access data from XML:http://jorgediazblog.wordpress.com/2012/06/27/work-item-customization-httpconector-and-oauth-in-rtc-4-0-for-oslc/ if your web service can be called using an URI and returns data the HTTP filtered value provider can access, you can use that in JavaScript - or even without JavaScript as described in Lab 4 here: https://jazz.net/library/article/1093.