【问题标题】:Consume SOAP WebService on Sencha?在 Sencha 上使用 SOAP WebService?
【发布时间】:2014-11-11 19:49:46
【问题描述】:

我一直在对煎茶上的 HelloWorld 进行一些测试,但无论如何我无法让它在 responseXML 上工作。我的代码是这样的......

Ext.Ajax.request({
       url: 'http://url/MobileService/MobileWS.asmx',
       callbackKey: 'callback',
       scope: 'this',
       method: 'POST',
       headers: {'Content-Type': 'application/soap+xml; charset=utf-8; action="http://tempuri.org/HelloWorld"'},
       success: function(response) {
          // OK
           alert("ok");
           alert(response.responseXML);

       },
        failure: function(response) {
          // KO
            alert("errpr");
            alert(response.resposeText);
       },
       xmlData: '<?xml version="1.0" encoding="utf-8"?>\n<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns="http://tempuri.org/HelloWorld"><soap:Header/><soap:Body><HelloWorldResult>string</HelloWorldResult></soap:Body></soap:Envelope>'
     });

这段代码在 responseText 中返回了我需要的所有 xml 信息,但没有显示在 responseXML 中。此外,我不知道如何查找 XML 键并获取值。

当我想使用更大的服务时遇到了真正的问题,我必须在其中包含一些输入参数。问题,它根本不起作用。也许果酱做错了。我只是将它添加到标题键之前的其他代码中。

params:{filter:'SomeName'}

我一直在阅读一些 sencha 文档,我发现应该有一些方法来创建模型和源以使用 SOAP WebService,但我无法做到这一点。有什么帮助吗?

【问题讨论】:

    标签: web-services extjs soap sencha-touch


    【解决方案1】:

    在某个地方找到了这个。这不是我的:

    为了让浏览器解析返回的 XML 文档,HTTP 响应中的 Content-Type 标头必须设置为“text/xml”或“application/xml”。这非常重要——否则 XmlReader 将无法正常工作。

    除此之外,您可能还想使用 JSON。 试试这个链接:

    http://davidwalsh.name/convert-xml-json
    

    【讨论】:

      猜你喜欢
      • 2016-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多