tags:

views:

566

answers:

1

This my 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 what i am getting error

n build.
*** 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"&gt;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"&gt;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>>
A: 

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()
Thanks lot .. man
rajaneesh
please tell me if any other good method .. i am beginner now . i am learning python now .. please suggest me ... which book i can read
rajaneesh
What kind of book are you looking for? For general introductions there are "Programming in Python 3" by Mark Summerfield, "Beginning Python: From Novice to Professional" by Magnus Lie Hetland, and more.
class Test: def __init__(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): return "Hello World"now i change my code i want argument should be client how to do that
rajaneesh
server.registerObject(Test(data))
rajaneesh
data should send client ... how to do that
rajaneesh
Sorry, but I'm not that familiar with SOAPpy. BTW, SOAPpy is years old. I recommend suds: https://fedorahosted.org/suds/
please give me sample code suds how to use with same example
rajaneesh