Click here to Skip to main content
Rate this: bad
good
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;
import javax.xml.ws.Endpoint;
 
@WebService
public class Area
{
    @WebMethod
    public double square(@WebParam(name="side") double side)
    {
        return side * side;
    }
 
    @WebMethod
    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.
	System.out.println(url+"?wsdl");
	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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript">
function call()
{
    var side = sideid.value;
    var req = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://ws.example.com/\"><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;
            alert(response.selectSingleNode(".//return").text);
        }
    }
    var soapaction = "http://ws.example.com/square";
    xmlhttp.open("POST","http://localhost:8080/area?wsdl",true);
    xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlhttp.setRequestHeader("SOAPAction", soapaction);
    xmlhttp.send(req);
}
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.4K
v3
Comments
Prasad Khandekar at 19-Apr-13 9:03am
   
What errors are you getting? Have you tried using http://www.guru4.net/articoli/javascript-soap-client/en/

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

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.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