Click here to Skip to main content
13,088,101 members (69,357 online)
Rate this:
Please Sign up or sign in to vote.
See more:
java code;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
public class Area
    public double square(@WebParam(name="side") double side)
        return side * side;
    public double rectangle(@WebParam(name="length") double length,@WebParam(name="breadth") double breadth)
        return length * breadth;
    public static void main(String[] args)
	Area area = new Area();
	String url = "http://localhost:8080/area"; // end point of webservice.
	Endpoint.publish(url, area); // publishing the webservice

this is html and java script code but i cant able to run
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<script language="javascript">
function call()
    var side = sideid.value;
    var req = "<soapenv:Envelope xmlns:soapenv=\"\" xmlns:web=\"\"><soapenv:Body><web:square><side>" + side+ "</side></web:square></soapenv:Body></soapenv:Envelope>";
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    var reqXML = xmlDoc.loadXML(req);
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            var response = xmlhttp.responseXML;
    var soapaction = "";"POST","http://localhost:8080/area?wsdl",true);
    xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlhttp.setRequestHeader("SOAPAction", soapaction);

kindly any one help me how to call webservice using java script
Posted 19-Apr-13 2:53am
Updated 19-Apr-13 2:59am
Prasad Khandekar 19-Apr-13 9:03am
What errors are you getting? Have you tried using

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100