var xhr;
if(window.ActiveXObject){
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}
function sendMsg(){
var name = document.getElementById('name').value;
//服务的地址
var wsUrl = 'http://localhost:9001/Service/ServiceHello';
//请求体http://schemas.xmlsoap.org/wsdl/soap/
var soap = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap12:Envelope xmlns:soap12="http://schemas.xmlsoap.org/soap/envelope/"' +
'xmlns:q0="http://www.chtest.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap12:Body> <q0:sayHello><arg0>'+
name+'</arg0> </q0:sayHello> </soap12:Body> </soap12:Envelope>';
//打开连接
xhr.open('POST',wsUrl,true);
//重新设置请求头
xhr.setRequestHeader("Content-Type","text/xml;charset=UTF-8");
//设置回调函数
xhr.onreadystatechange = _back;
//发送请求
xhr.send(soap);
}

https://zhidao.baidu.com/question/647895225724483365.html