ajax调用webServices不成功。求指教
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://img-ask.csdn.net/upload/201609/02/1472781495_696361.png)

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问