N
Nestor
Hello all,
I'm begining in the web services world and I've reading about how to
invoke them using javascript from Mozilla browser (version 2.0 in my
case).
I found a very interesting example here:
http://www.mozilla.org/projects/webservices/examples/babelfish-wsdl/index.html
The problem I have is this: When I try to adapt the invokation on the
example above by using the proper parameters I don't get the desired
output (in fact I don't get any output).
I have to invoke the service located at:
http://193.146.58.138:8080/axis/WS6Sep.jws . The WSDL file is here:
http://193.146.58.138:8080/axis/WS6Sep.jws?wsdl
In order to create the service request I copied the main babelfish
example page and I adapted the javascript file called in the main page,
which now looks like this (the main page is the same in my call):
var proxy = null;
var wsdl_uri = "http://193.146.58.138:8080/axis/WS6Sep.jws?wsdl";
//Aqui se llama a la traduccion
function Translate (aValue)
{
if (!proxy) {
alert("creating proxy");
var listener = {
onLoad: function (aProxy)
{
proxy = aProxy;
proxy.setListener(listener);
requestTranslation(aValue);
},
onError: function (aError)
{
alert(aError);
},
getURLCallback : function (aTranslatedValue)
{
document.getElementById("results").innerHTML=aTranslatedValue;
}
};
createProxy(listener);
}
else {
alert("I request the service");
requestTranslation(aValue);
}
}
//here I create the listener
function createProxy(aCreationListener)
{
alert ("here it begins the funcion that creates the proxy");
try {
var factory = new WebServiceProxyFactory();
factory.createProxyAsync(wsdl_uri, "WS6Sep", "", true,
aCreationListener);
alert("CORRECT: the proxy has been created succesfully");
}
catch (ex) {
alert("I have an error");
alert(ex);
alert("the proxy hasn't been created");
}
alert("CREATE proxy function ends here");
}
//Here I've to send the parameters to the service
//OLD babel fish function has been comented and copied below
/* function requestTranslation (value)
{
if (proxy) {
var parambabel="en_pt";
if (document.forms[1].optionto[0].checked) parambabel="en_pt";
if (document.forms[1].optionto[1].checked) parambabel="en_fr";
if (document.forms[1].optionto[2].checked) parambabel="en_de";
proxy.BabelFish(parambabel, value);
}
else {
alert("Error: Proxy set up not complete!");
}
}*/
function requestTranslation (value)
{
alert ("I send the request");
if (proxy) {
alert("proxy ok, sending request");
// var val = proxy.getURL(value);//value =Competency
var val = proxy.getURL("Competency");//value =Competency
alert("proxy ok, the response has been received");
}
else {
alert("Error: Proxy set up not complete!");
}
}
The value "Competency" is used because it is one of the few that are
available at the moment. ( in the future I'll have to receive it from
a form so I didn't deleted the code)
Do you know how can I solve my problem and get the correct output?
(which, I think, should look like an URL)
I will thank you very much any idea you may have because I have to call
the service as soon as possible and I don't know what else I can do in
order to do it.
Thanks a lot in advance.
Néstor
I'm begining in the web services world and I've reading about how to
invoke them using javascript from Mozilla browser (version 2.0 in my
case).
I found a very interesting example here:
http://www.mozilla.org/projects/webservices/examples/babelfish-wsdl/index.html
The problem I have is this: When I try to adapt the invokation on the
example above by using the proper parameters I don't get the desired
output (in fact I don't get any output).
I have to invoke the service located at:
http://193.146.58.138:8080/axis/WS6Sep.jws . The WSDL file is here:
http://193.146.58.138:8080/axis/WS6Sep.jws?wsdl
In order to create the service request I copied the main babelfish
example page and I adapted the javascript file called in the main page,
which now looks like this (the main page is the same in my call):
var proxy = null;
var wsdl_uri = "http://193.146.58.138:8080/axis/WS6Sep.jws?wsdl";
//Aqui se llama a la traduccion
function Translate (aValue)
{
if (!proxy) {
alert("creating proxy");
var listener = {
onLoad: function (aProxy)
{
proxy = aProxy;
proxy.setListener(listener);
requestTranslation(aValue);
},
onError: function (aError)
{
alert(aError);
},
getURLCallback : function (aTranslatedValue)
{
document.getElementById("results").innerHTML=aTranslatedValue;
}
};
createProxy(listener);
}
else {
alert("I request the service");
requestTranslation(aValue);
}
}
//here I create the listener
function createProxy(aCreationListener)
{
alert ("here it begins the funcion that creates the proxy");
try {
var factory = new WebServiceProxyFactory();
factory.createProxyAsync(wsdl_uri, "WS6Sep", "", true,
aCreationListener);
alert("CORRECT: the proxy has been created succesfully");
}
catch (ex) {
alert("I have an error");
alert(ex);
alert("the proxy hasn't been created");
}
alert("CREATE proxy function ends here");
}
//Here I've to send the parameters to the service
//OLD babel fish function has been comented and copied below
/* function requestTranslation (value)
{
if (proxy) {
var parambabel="en_pt";
if (document.forms[1].optionto[0].checked) parambabel="en_pt";
if (document.forms[1].optionto[1].checked) parambabel="en_fr";
if (document.forms[1].optionto[2].checked) parambabel="en_de";
proxy.BabelFish(parambabel, value);
}
else {
alert("Error: Proxy set up not complete!");
}
}*/
function requestTranslation (value)
{
alert ("I send the request");
if (proxy) {
alert("proxy ok, sending request");
// var val = proxy.getURL(value);//value =Competency
var val = proxy.getURL("Competency");//value =Competency
alert("proxy ok, the response has been received");
}
else {
alert("Error: Proxy set up not complete!");
}
}
The value "Competency" is used because it is one of the few that are
available at the moment. ( in the future I'll have to receive it from
a form so I didn't deleted the code)
Do you know how can I solve my problem and get the correct output?
(which, I think, should look like an URL)
I will thank you very much any idea you may have because I have to call
the service as soon as possible and I don't know what else I can do in
order to do it.
Thanks a lot in advance.
Néstor