ChaoBaby94 2016-02-27 02:40 采纳率: 0%
浏览 2840

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

肿么解决!

  • 写回答

4条回答 默认 最新

  • ChaoBaby94 2016-02-27 03:21
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制