Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: Java
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 3:53am
Edited 19-Apr-13 3:59am
(no name)47.8K
Prasad Khandekar at 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)

Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
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