File: complexTypes.txt

package info (click to toggle)
python-soappy 0.9.7-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 500 kB
  • ctags: 1,020
  • sloc: python: 7,572; makefile: 43; sh: 16
file content (153 lines) | stat: -rw-r--r-- 5,029 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Copyright (c) 2001, actzero, inc.

SOAP.py 0.9.5 - Cayce Ullman   (cayce@actzero.com)
                Brian Matthews (blm@actzero.com)

MANIFEST:
quickstart.txt
../SOAP.py       the library
../SOAPtest.py   tests the builder and parser
../echoClient.py an example client
../echoServer.py an example server
../speedTest.py  benchmarks the various parsers, compares speed to DOM
../TCtest.py     experimental type coercion system tests
../tests/*       examples
../validate/*    interop client and servers
../bid/*	      N+I interop client and server


HOWTO:

The easiest ways to understand use of complex types is to look at examples of
working code, to look at the wiredumps, and to write new client and server 
implementations.

SOAP.py has a Header class to hold data for the header of a SOAP message.
Each Header instance has methods to set/get the  MustUnderstand attribute, and
methods to set/get the Actor attribute.

SOAP.py also has a SOAPContext class so that each server method can be 
implemented in such a way that it gets the context of the connecting client.
This includes both common SOAP information and connection information (see 
below for an example).



CLIENT EXAMPLES:

## CODE
import SOAP
test = 42
server = SOAP.SOAPProxy("http://localhost:8888")
server = server._sa ("urn:soapinterop")

hd = SOAP.Header()
hd.InteropTestHeader ='This should fault, as you don\'t understand the header.'
hd._setMustUnderstand ('InteropTestHeader', 0)
hd._setActor ('InteropTestHeader','http://schemas.xmlsoap.org/soap/actor/next')
server = server._hd (hd)

print server.echoInteger (test)
## /CODE

This should succeed (provided the server has defined echoInteger), as it
builds a valid header into this client with MustUnderstand set to 0
and then sends the SOAP with this header.


## CODE
import SOAP
test = 42
server = SOAP.SOAPProxy("http://localhost:8888")
server = server._sa ("urn:soapinterop")
#Header
hd = SOAP.Header()
hd.InteropTestHeader = 'This should fault,as you don\'t understand the header.'
hd._setMustUnderstand ('InteropTestHeader', 1)
hd._setActor ('InteropTestHeader','http://schemas.xmlsoap.org/soap/actor/next')
server = server._hd (hd)

print server.echoInteger (test)
## /CODE

This should fail (even if the server has defined 'echoInteger'), as it
builds a valid header into this client, but sets MustUnderstand to 1
for a message that the server presumably won't understand before sending.  




SERVER EXAMPLES:

## CODE
import SOAP
def echoInteger (inputInteger):
    return inputInteger
server = SOAP.SOAPServer ( ('localhost', 8080) )
server.registerFunction (echoInteger)
server.serve_forever()
## /CODE

This is a simple server designed to work with the first 2 clients above. 


## CODE
import SOAP
def echoInteger (inputInteger, _SOAPContext):
    c = _SOAPContext
    print c.xmldata
    print c.header
    print c.body
    print c.connection.getpeername()
    print c.soapaction
    print c.httpheaders
    return inputInteger

host = 'localhost'
port = 8888

server = SOAP.SOAPServer ( (host, port) )
server.registerFunction (SOAP.MethodSig(echoInteger, keywords=0,context=1))

server.serve_forever()
## /CODE

This is a server which shows off the SOAPContext feature.  This server gets a
context from the client that has connected to it, and prints some of the 
pertinent aspects of that client before returning.
This server should also work with the code for the two clients written above.





Copyright (c) 2001, actzero, inc.
Copyright (c) 2001, Cayce Ullman.

All rights reserved.

LICENSE:
--------------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Neither the name of actzero, inc. nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.