【问题标题】:JavaScript SOAP client throwing an Uncaught TypeErrorJavaScript SOAP 客户端抛出 Uncaught TypeError
【发布时间】:2011-11-12 22:55:53
【问题描述】:

我正在使用guru4's soap client 编写一个简单的“Hello world”程序。我从 Chrome 控制台 Uncaught TypeError: Cannot read property 'documentElement' of null 收到错误消息。

这是我的 JavaScript。

  <script src="soapclient.js"></script>
  <script type="text/javascript">
    function say_hello()
    {

        var pl = new SOAPClientParameters();
        pl.add("name", "john");
        pl.add("times", 2);
        SOAPClient.invoke("http://192.168.1.100:7789/", "say_hello", pl, true, say_hello_callBack);
    }
    function say_hello_callBack(r)
    {
        alert(r);
    }
  </script>

这是我尝试与之交互的服务器。

import soaplib

from soaplib.core.service import soap
from soaplib.core.service import DefinitionBase
from soaplib.core.model.primitive import String, Integer

from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array

'''
This is a simple HelloWorld example to show the basics of writing
a webservice using soaplib, starting a server, and creating a service
client.
'''

class HelloWorldService(DefinitionBase):
    @soap(String, Integer, _returns=Array(String))
    def say_hello(self, name, times):
        '''
        Docstrings for service methods appear as documentation in the wsdl
        <b>what fun</b>
        @param name the name to say hello to
        @param the number of times to say hello
        @return the completed array
        '''
        results = []
        for i in range(0, times):
            results.append('Hello, %s' % name)
        return results

if __name__=='__main__':
    try:
        from wsgiref.simple_server import make_server
        soap_application = soaplib.core.Application([HelloWorldService], 'tns')
        wsgi_application = wsgi.Application(soap_application)

        print "listening to http://0.0.0.0:7789"
        print "wsdl is at: http://127.0.0.1:7789/?wsdl"

        server = make_server('localhost', 7789, wsgi_application)
        server.serve_forever()

    except ImportError:
        print "Error: example server code requires Python >= 2.5"

我感觉这个错误正在发生,因为我依赖于 SOAP 客户端内置的 XML 生成器。

【问题讨论】:

    标签: javascript python soap wsdl soaplib


    【解决方案1】:

    您可以打开“Web Developer Tools”(Ctrl+Shift+J)并查看在 JS 代码处。可能没有 WSDL。可能是结果消息的名称不受此“JavaScript SOAP 客户端”支持(应命名为 MethodName + "Result",例如 LoginResult)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 2015-10-14
      • 2020-09-10
      • 1970-01-01
      相关资源
      最近更新 更多