0

i am trying to call a web service from my pure HTML page using java script. i had successfully created a web service using java on net beans. now i want to call a method from that web service using java script with sending some parameters to the web Service, i had tried so far but not succeed yet. i had successfully called the method using jsp page, but i need to do it by using simple html page.

i had seen an example Here but it is not working with me. :(

can you please give me some example, so that i come to know how to call a specific method of my web service from java script with sending some parameters to the web service.

thanks in advance.

EDIT

my script

    function validateForm(frm)
{ 
document.forms[0].action="http://localhost:8084/Web_Service_Example/CircleFunctions?"
document.forms[0].method="post"
document.forms[0].submit()
}

my CircleFunctions method

public class CircleFunctions {
public int sum()

{
    int a = 20;
    int b = 40;

    int c = a+b;

    return c;
}
}
Community
  • 1
  • 1
pra....
  • 23
  • 9
  • 1
    Are you trying to make the request to the same domain? Or are you trying to call a web service from a different location? – Justin Beckwith May 07 '12 at 05:39
  • @JustinBeckwith i am trying to call a web service from a different location, i.e. from my local server or system. – pra.... May 07 '12 at 05:42
  • 1
    Heh, you just said two different things :-) Could you post your JavaScript? – Justin Beckwith May 07 '12 at 05:45
  • @Justin Beckwith Actualy upto now i didn't wrote any java script, i just doing R&D for that. i had tried the answer which is given by Satya but it is showing me the XML page only. – pra.... May 07 '12 at 06:10

1 Answers1

1
document.forms[0].action="http://localhost:8080/webservice/services/add"
document.forms[0].method="get"
document.forms[0].submit()
Satya
  • 8,693
  • 5
  • 34
  • 55
  • it shows me direct XML page of web service. i neeed to call directly function of that web service. – pra.... May 07 '12 at 06:07
  • thnks for change in code, it is calling my web service but not showing the output, is says "Hi there, this is an AXIS service!" but when i directly run my web service it shows the output. can u please help me a bit more. – pra.... May 07 '12 at 06:22
  • can you paste what is the actual URL you need to call for your ws – Satya May 07 '12 at 06:23
  • as far as I can see you are not passing any param to add method , so I have updated my code to call add directly try that – Satya May 07 '12 at 06:35
  • still the same.. :( "Hi there, this is an AXIS service!" – pra.... May 07 '12 at 06:41
  • when you paste this URL http://localhost:8080/webservice/services/add in your browser what do you get. Also paste this URL http://localhost:8080/webservice/add and let me know the output of these 2 – Satya May 07 '12 at 06:42
  • on first link the error is same that is "Hi there, this is an AXIS service!" and on second one the error 404 (The requested resource (/webservice/add) is not available). – pra.... May 07 '12 at 06:48
  • localhost:8080/webservice/services/add/sum paste this URL and let me know the output – Satya May 07 '12 at 06:52
  • Error 404(The requested resource (/webservice/add/sum) is not available). :( – pra.... May 07 '12 at 06:54
  • paste your WSDL pl localhost:8080/webservice/services/add?WSDL – Satya May 07 '12 at 07:02
  • not working yar... :( :( error is same that is "Hi there, this is an AXIS service!" is there any other way to do that..?? – pra.... May 07 '12 at 07:06