jquery+ajax调用webservice
后台的java代码已经发布到webservice上了:但是就是运行前端,什么反应都没有,求解答
后台:
public class HelloService
{
public String say(String name)
{
System.out.println("你好" + name);
return name;
}
}
前端:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>jquery_wsl.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-1.11.2.js"></script>
<script type="text/javascript">
function sendMsg(){
var name="jimmy";
$.ajax({
url: 'http://localhost:8082/axis/services/Jhellowservice?wsdl/say',
type:'post',
dataType:'xml',
contentType:'text/xml;charset=utf-8',
data:'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:say xmlns:ns2="http://cxf.njupt.com/"><arg0>'+name+'</arg0></ns2:say></soap:Body></soap:Envelope>',
success:function(){
alert("成功");
},
error:function(){
alert('error');
}
});
}
</script>
</head>
<body>
<input type="button" value="使用jquery的ajax方法调用webservice服务" onclick="sendMsg()"/>
</body>
</html>