~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/web/examples/soap.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
 
5
"""Example of publishing SOAP methods.
 
6
 
 
7
Sample usage::
 
8
 
 
9
   >>> import SOAPpy
 
10
   >>> p = SOAPpy.SOAPProxy('http://localhost:8080/')
 
11
   >>> p.add(a=1)
 
12
   1
 
13
   >>> p.add(a=1, b=3)
 
14
   4
 
15
   >>> p.echo([1, 2])
 
16
   [1, 2]
 
17
 
 
18
"""
 
19
 
 
20
from twisted.web import soap, server
 
21
from twisted.internet import reactor, defer
 
22
 
 
23
 
 
24
class Example(soap.SOAPPublisher):
 
25
    """Publish two methods, 'add' and 'echo'."""
 
26
 
 
27
    def soap_echo(self, x):
 
28
        return x
 
29
 
 
30
    def soap_add(self, a=0, b=0):
 
31
        return a + b
 
32
    soap_add.useKeywords = 1
 
33
 
 
34
    def soap_deferred(self):
 
35
        return defer.succeed(2)
 
36
 
 
37
 
 
38
reactor.listenTCP(8080, server.Site(Example()))
 
39
reactor.run()
 
40
 
 
41