Python SOAPpy错误

Python SOAPpy错误,python,soappy,Python,Soappy,下面是我的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.hell

下面是我的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()
服务器部分

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()
客户端部分

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>>
***传出HTTP头**********************************************
POST/HTTP/1.0
主持人:127.0.0.1:5551
用户代理:SOAPpy 0.12.0(http://pywebsvcs.sf.net)
内容类型:text/xml;charset=“UTF-8”
内容长度:350
SOAPAction:“Test.hello”
************************************************************************
***传出SOAP******************************************************
************************************************************************
代码=500
msg=内部服务器错误
headers=Server:(Python 2.5.2)
日期:2009年7月27日星期一07:25:40 GMT
内容类型:text/xml;charset=“UTF-8”
内容长度:674
内容类型=文本/xml;charset=“UTF-8”
数据=
SOAP-ENV:客户端
找不到方法
Test.hello:在0x9fbcb44处键入“exceptions.KeyError”无回溯对象
***传入的HTTP头**********************************************
HTTP/1。?500内部服务器错误
服务器:(Python 2.5.2)
日期:2009年7月27日星期一07:25:40 GMT
内容类型:text/xml;charset=“UTF-8”
内容长度:674
************************************************************************
***来料肥皂******************************************************
SOAP-ENV:客户端
找不到方法
Test.hello:在0x9fbcb44处键入“exceptions.KeyError”无回溯对象
************************************************************************
回溯(最近一次呼叫最后一次):
文件“/home/rajaneesh/workspace/raju/src/call.py”,第4行,在
打印服务器.Test.hello()
文件“/var/lib/pythonsupport/python2.5/SOAPpy/Client.py”,第470行,在调用__
返回自。\ r\u调用(*参数,**千瓦)
文件“/var/lib/pythonsupport/python2.5/SOAPpy/Client.py”,第492行,在
self.\uuuhd,self.\uma)
文件“/var/lib/pythonsupport/python2.5/SOAPpy/Client.py”,第406行,在调用
提高p
SOAPpy.Types.faultType:

您真的想让test()成为类方法吗?我建议您像这样更改代码

class Test:
  def hello(self):
    return "Hello World"
然后必须创建测试类的实例并注册:

server.registerObject(Test())
然后,客户端可以访问hello()方法,如下所示:

print server.hello()

如果还有其他好方法,请告诉我。。我现在是初学者。我正在学习python。。请建议我。。。我能读哪本书你在找哪种书?对于一般介绍,有马克·萨默菲尔德的“Python 3编程”,马格努斯·李·赫特兰的“开始Python:从新手到专业人士”,以及更多内容。类测试:def _uinit _uu_u;(self,initdata):if initdata['style']='FileDetails':self.host=initdata['host']self.usr=initdata['usr']self.pwd=initdata['pwd']self.database=initdata['database']self.sql=initdata['sql']self.path=initdata['path']def hello(self):返回“hello World”现在我更改了代码我想要的参数应该是客户端如何做那件事server.registerObject(Test(data))数据应该发送到客户端。。。怎么做