Python SOAPpy 错误

发布于 2024-07-29 17:41:28 字数 4585 浏览 12 评论 0原文

下面是我的 Python 代码:

服务部分

class Test:
    def hello():
        return "Hello World"

服务器部分

import SOAPpy
from first_SOAP import *

host = "127.0.0.1"
port = 5551
SOAPpy.Config.debug = 1
server = SOAPpy.SOAPServer((host, port))
server.registerKWFunction(Test.hello)
print "Server Runing"

server.serve_forever(

客户端部分

import SOAPpy
SOAPpy.Config.debug = 1
server = SOAPpy.SOAPProxy("http://127.0.0.1:5551/")
print server.Test.hello()

这是我收到的错误:

*** Outgoing HTTP headers **********************************************
POST / HTTP/1.0
Host: 127.0.0.1:5551
User-agent: SOAPpy 0.12.0 (http://pywebsvcs.sf.net)
Content-type: text/xml; charset="UTF-8"
Content-length: 350
SOAPAction: "Test.hello"
************************************************************************
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>
<SOAP-ENV:Body>
<Test.hello SOAP-ENC:root="1">
</Test.hello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
code= 500
msg= Internal Server Error
headers= Server: <a href="http://pywebsvcs.sf.net">SOAPpy 0.12.0</a> (Python 2.5.2)
Date: Mon, 27 Jul 2009 07:25:40 GMT
Content-type: text/xml; charset="UTF-8"
Content-length: 674

content-type= text/xml; charset="UTF-8"
data= <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENC:root="1">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Method Not Found</faultstring>
<detail xsi:type="xsd:string">Test.hello : &lt;type 'exceptions.KeyError'&gt; None &lt;traceback object at 0x9fbcb44&gt;</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

*** Incoming HTTP headers **********************************************
HTTP/1.? 500 Internal Server Error
Server: <a href="http://pywebsvcs.sf.net">SOAPpy 0.12.0</a> (Python 2.5.2)
Date: Mon, 27 Jul 2009 07:25:40 GMT
Content-type: text/xml; charset="UTF-8"
Content-length: 674
************************************************************************
*** Incoming SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENC:root="1">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Method Not Found</faultstring>
<detail xsi:type="xsd:string">Test.hello : &lt;type 'exceptions.KeyError'&gt; None &lt;traceback object at 0x9fbcb44&gt;</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
<Fault SOAP-ENV:Client: Method Not Found: Test.hello : <type 'exceptions.KeyError'> None <traceback object at 0x9fbcb44>>
Traceback (most recent call last):
  File "/home/rajaneesh/workspace/raju/src/call.py", line 4, in <module>
    print server.Test.hello()
  File "/var/lib/python-support/python2.5/SOAPpy/Client.py", line 470, in __call__
    return self.__r_call(*args, **kw)
  File "/var/lib/python-support/python2.5/SOAPpy/Client.py", line 492, in __r_call
    self.__hd, self.__ma)
  File "/var/lib/python-support/python2.5/SOAPpy/Client.py", line 406, in __call
    raise p
SOAPpy.Types.faultType: <Fault SOAP-ENV:Client: Method Not Found: Test.hello : <type 'exceptions.KeyError'> None <traceback object at 0x9fbcb44>>

Below is my Python code:

Service part

class Test:
    def hello():
        return "Hello World"

Server Part

import SOAPpy
from first_SOAP import *

host = "127.0.0.1"
port = 5551
SOAPpy.Config.debug = 1
server = SOAPpy.SOAPServer((host, port))
server.registerKWFunction(Test.hello)
print "Server Runing"

server.serve_forever(

Client part

import SOAPpy
SOAPpy.Config.debug = 1
server = SOAPpy.SOAPProxy("http://127.0.0.1:5551/")
print server.Test.hello()

This the error that I'm getting:

*** Outgoing HTTP headers **********************************************
POST / HTTP/1.0
Host: 127.0.0.1:5551
User-agent: SOAPpy 0.12.0 (http://pywebsvcs.sf.net)
Content-type: text/xml; charset="UTF-8"
Content-length: 350
SOAPAction: "Test.hello"
************************************************************************
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>
<SOAP-ENV:Body>
<Test.hello SOAP-ENC:root="1">
</Test.hello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
code= 500
msg= Internal Server Error
headers= Server: <a href="http://pywebsvcs.sf.net">SOAPpy 0.12.0</a> (Python 2.5.2)
Date: Mon, 27 Jul 2009 07:25:40 GMT
Content-type: text/xml; charset="UTF-8"
Content-length: 674

content-type= text/xml; charset="UTF-8"
data= <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENC:root="1">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Method Not Found</faultstring>
<detail xsi:type="xsd:string">Test.hello : <type 'exceptions.KeyError'> None <traceback object at 0x9fbcb44></detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

*** Incoming HTTP headers **********************************************
HTTP/1.? 500 Internal Server Error
Server: <a href="http://pywebsvcs.sf.net">SOAPpy 0.12.0</a> (Python 2.5.2)
Date: Mon, 27 Jul 2009 07:25:40 GMT
Content-type: text/xml; charset="UTF-8"
Content-length: 674
************************************************************************
*** Incoming SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENC:root="1">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Method Not Found</faultstring>
<detail xsi:type="xsd:string">Test.hello : <type 'exceptions.KeyError'> None <traceback object at 0x9fbcb44></detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
<Fault SOAP-ENV:Client: Method Not Found: Test.hello : <type 'exceptions.KeyError'> None <traceback object at 0x9fbcb44>>
Traceback (most recent call last):
  File "/home/rajaneesh/workspace/raju/src/call.py", line 4, in <module>
    print server.Test.hello()
  File "/var/lib/python-support/python2.5/SOAPpy/Client.py", line 470, in __call__
    return self.__r_call(*args, **kw)
  File "/var/lib/python-support/python2.5/SOAPpy/Client.py", line 492, in __r_call
    self.__hd, self.__ma)
  File "/var/lib/python-support/python2.5/SOAPpy/Client.py", line 406, in __call
    raise p
SOAPpy.Types.faultType: <Fault SOAP-ENV:Client: Method Not Found: Test.hello : <type 'exceptions.KeyError'> None <traceback object at 0x9fbcb44>>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆萌少年 2024-08-05 17:41:28

你真的想让 test() 成为一个类方法吗? 我建议你像这样改变你的代码。

class Test:
  def hello(self):
    return "Hello World"

然后,您必须创建 Test 类的实例并注册:

server.registerObject(Test())

然后客户端可以像这样访问 hello() 方法:

print server.hello()

Do you really want to make test() a class method? I suggest you change your code like this.

class Test:
  def hello(self):
    return "Hello World"

Then you must create an instance of the Test class and register:

server.registerObject(Test())

Then the client can access the hello() method like this:

print server.hello()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文