Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/03/2015, 12:05
lokinkc
 
Fecha de Ingreso: abril-2013
Mensajes: 2
Antigüedad: 11 años
Puntos: 0
Consumiento un webservice SOAP a traves de JavaScript

Buenas, estoy intentando consumir un Webservice hecho en java desde un cliente JavaScript.
Consigo, desde el cliente, acceder al jsp del webservice, pero no a ninguno de sus metodos.
No he hecho esto nunca, y no se si lo estoy haciendo bien o si se puede hacer siquiera lo que yo quiero.

Dejo aquí mi código para ver si alguien me puede ayudar.


Codigo:

Código:
<html>

<script type="text/javascript">
	
    function run(){

        var objXMLHttpRequest = new XMLHttpRequest();
        objXMLHttpRequest.open("GET", "http://localhost:8080/CrunchifyWS/services/CrunchifyHelloWorld?wdsl/getText", true);
        objXMLHttpRequest.onreadystatechange = function () {
       	//alert(objXMLHttpRequest.readyState+"   "+ objXMLHttpRequest.status);
        if (objXMLHttpRequest.readyState == 4 && objXMLHttpRequest.status == 200) {
            result = objXMLHttpRequest.responseXML;
            alert(objXMLHttpRequest.responseText);
          }
        }
        objXMLHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

        var packet = '<?xml version="1.0" encoding="utf-8" ?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><PieTable xmlns="[getText(Namespace = "http://service.web.com.crunchify")]"><table>Pie</table></PieTable></soap:Body></soap:Envelope>';

        objXMLHttpRequest.send(packet);
        // Add mentioned below code only if your application calls webservice synchronously. Otherwise use "onreadystatechange" process response.
        response = objXMLHttpRequest.responseXML;
        alert(objXMLHttpRequest.responseText+ "  "+ response);
    }
</script>

<head>
</head>
<body>
	<button  onclick="run()">Dale!</button>
</body>
</html>
Muchas gracias de antemano. Estoy seguro de que lo estoy haciendo mal. Pero no se muy bien por qué.