ajax方式调用WebService

    $.ajax({
        url:'http://127.0.0.1:6789/hello',type:'post',
        contentType:'text/xml;charset=utf-8',
        data:'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://ws.demo2/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
            '<soapenv:Body><q0:sayHello><arg0>aaa</arg0></q0:sayHello></soapenv:Body></soapenv:Envelope>',
        dataType:'xml',
        success:function(msg){
            // ...
            alert("调用WebService成功!");
        },
        error:function(XMLHttpRequest,textStatus,errorThrown){
            alert("ajax调用错误!");
        }
    });

    然后HelloService的控制台输出:二月 27, 2016 10:35:03 上午 com.sun.xml.internal.ws.transport.http.server.WSHttpHandler handleExchange

警告: 无法处理 HTTP 方法: OPTIONS

网页的控制台:OPTIONS http://127.0.0.1:6789/hello net::ERR_EMPTY_RESPONSE

n.ajaxTransport.k.cors.a.crossDomain.send @ jquery.min.js:4
n.extend.ajax @ jquery.min.js:4
(anonymous function) @ ajax_ws.html:33
n.event.dispatch @ jquery.min.js:3
n.event.add.r.handle @ jquery.min.js:3

肿么解决!

补充:
已经知道$.ajax();的data必须以key/value的形式,但是SOAP里面就一个XML。没有key啊?怎么办

将soap作为一个字符串发送过去,,“”引号用/"进行转义

你的webservice接受数据 那么就不能直接发送soap数据 而是自己先处理好再发送

请问楼主怎么解决的,我也遇到了相同问题,用原生ajax可以搞定,但是用jq的ajax方法和你出现相同问题,求指教