2009-07-27 1 views
0

Ниже мой код Python:Python SOAPpy Ошибки

служба часть

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>> 

ответ

0

Вы действительно хотите, чтобы сделать тест() метод класса? Я предлагаю вам изменить свой код следующим образом.

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

Затем необходимо создать экземпляр класса Test и регистрации:

server.registerObject(Test()) 

Затем клиент может получить доступ к методу привет(), как это:

print server.hello() 
+0

спасибо много .. мужчина – rajaneesh

+0

сообщите пожалуйста если какой-либо другой хороший способ .. я начинающий сейчас. Я изучаю python сейчас .. пожалуйста, предложите мне ... какую книгу я могу прочитать – rajaneesh

+0

Какую книгу вы ищете? Для общих представлений есть «Программирование на Python 3» Марка Саммерфилда, «Начало Python: от новичка к профессионалу» Магнуса Ли Хетланд и многое другое. – 2009-07-27 09:14:45