Search code examples
javaajaxweb-servicesaxistomcat8

How to call an AXIS web service via AJAX?


I'm very new to web services. I used eclipse and some tutorials from the web to create a simple web service called DeScriptor which I uploaded to a Tomcat server. It's accessible through this URL

http://www.xwizard.de:8080/services/DeScriptor

and according to the message written out there, it appears to be working (right?).

So far, so good, but now I don't know how to call it. The service has a single method String retrieveSVGFromScript(String scrp) which I tried to call with this AJAX code:

var hallowelt = "Hallo Welt";
var params = JSON.stringify({scrp: hallowelt});

$.ajax({
    type: "POST",
    url: "http://www.xwizard.de:8080/services/DeScriptor/retrieveSVGFromScript",
    data: params,
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    crossDomain: true,
    success: function (msg) {
        console.log(msg.d);
    },
    error: function (xhr, status, error) {
        // Some error handling.
    }
});

hoping that I'd get the result string of the method by msg.d, but instead I got this not so informative error message:

jquery.js:8630 POST http://www.xwizard.de:8080/services/DeScriptor/retrieveSVGFromScript 500 (Internal Server Error)

Can somebody point me in the right direction?

EDIT: You can find the WSDL here: http://www.xwizard.de:8080/services/DeScriptor?wsdl


Solution

  • You are trying to call a server webservice using REST style (i.e. setting content-type, providing params as JSON message, etc.).

    But the webservice expects a SOAP message. An example how to send a SOAP message with Javascript can be found here.