469,950 Members | 2,305 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Help in accessing a Web service

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/webs...sdl/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=aTran slatedValue;
}

};

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

Dec 10 '06 #1
1 1733
Daz

Nestor wrote:
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/webs...dl/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
Your question seems somewhat complex, and comes across as saying that
'it's broken, how can I fix it?'

I believe I speak for the majority when I say that asking people for
help debugging an entire project might get you ignored. Instead, it
might pay off to try and debug it yourself with a JavaScript console
(which comes included in the latest version of Firefox, available from
www.getfirefox.com), and see what errors you get (if any), and then try
to fix it that way. If you are stuck, by all means, post the error(s)
here, and I am sure people will be happy to help you. However, if there
are no JavaScript errors, then your problem is not JavaScript related,
and is therefore off-topic.

Sorry I couldn't be of more assistance, and good luck with the
debugging. :)

Best regards.

Daz.
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=aTran slatedValue;
}

};

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
Dec 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike | last post: by
reply views Thread by RichardF | last post: by
3 posts views Thread by mark.jerrom | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.