0

I have a simple webservice written in JAVA using Eclipse and Axis2. I am trying to call the webservice using jQuery as:

<html>
<head>
    <title>Calling WebService</title>



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <script  language="javascript" type="text/javascript">
        function callws() {
            //code

          var userName ='TempUser';
          var password='1234';
          var soapMessage =
                  '<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> \
                  <Login xmlns="http://core.tst.com/"> \
                  <UserName>' + userName + '</UserName> \
                  <Password>' + password + '</Password> \
                  </Login> \
                  </soap:Body> \
                  </soap:Envelope>';

          $.ajax({
            type: "POST",
            url: "http://99.32.184.180:8080/TestLoginWS/services/BasicServices.BasicServicesHttpSoap11Endpoint?op=Login",
            data: soapMessage,
            contentType: "application/xml; charset=\"utf-8\"",
            dataType: "json",
            processData:false,
            success: function(msg){
                alert('Success');


            },
            error: function(e){
                alert('Error: ' + JSON.stringify(e));

$('#p1').html(JSON.stringify(e));            }
          });


        }
    </script>

</head>

<body>
    <form>
        <div>
            <input type="button" value="Go" onclick="callws()" />
        </div>
        <br><br><br>
        <p id="p1">


        </p>
    </form>
</body>
</html>

The error I get is: {"readyState":0,"responseText":"","status":0,"statusText":"error"} I am hosting the webservice and the page on the same server under Tomcat 7.

I saw lot of examples and help, unable to figure this out. Any help will be appreciated, thx

4

0 回答 0