I've looked through a number of posts/tutorials on calling a WS via AJAX, but am still not able to do this. Not that the environment matters but... I wrote my Java Class in Eclipse, I'm running it on GlassFish, and I'm able to hit the Endpoint via soapUI.
JAVA Class:
package com.tester.gf;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
@WebService
public class GlassFishTestApp {
public List<String> getBrands() {
List<String> brands = new ArrayList<>();
brands.add("Chevrolet");
brands.add("Dodge");
brands.add("Ford");
return brands;
}
}
Endpoint:
localhost:8080/GlassFishTestApp/GlassFishTestAppService?wsdl
When I load the following Web Page, I only see "Error: " displayed in the .
<html>
<head>
<title>SOAP WS Test</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function () {
$.ajax(
type: 'get',
url: 'http://localhost:8080/GlassFishTestApp/GlassFishTestAppService',
success: function (data) {
$('#results').text(data);
},
error: function (request, status, error) {
$('#results').text('Error: ' + request.responseText);
}
});
});
</script>
</head>
<body>
<div id="results"></div>
</body>
<html>
soapUI Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gf="http://gf.tester.com/">
<soapenv:Header/>
<soapenv:Body>
<gf:getBrands/>
</soapenv:Body>
</soapenv:Envelope>
soapUI Respose:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getBrandsResponse xmlns:ns2="http://gf.tester.com/">
<return>Chevrolet</return>
<return>Dodge</return>
<return>Ford</return>
</ns2:getBrandsResponse>
</S:Body>
</S:Envelope>
Thanks for any input on this!