1 | """SOAP common package for NDG SAML. |
---|
2 | |
---|
3 | Initially for use with SAML SOAP Bindings. This itself |
---|
4 | uses ElementTree. This SOAP interface provides an ElementTree interface to |
---|
5 | support it |
---|
6 | |
---|
7 | NERC DataGrid Project |
---|
8 | """ |
---|
9 | __author__ = "P J Kershaw" |
---|
10 | __date__ = "24/07/09" |
---|
11 | __copyright__ = "(C) 2009 Science and Technology Facilities Council" |
---|
12 | __license__ = "http://www.apache.org/licenses/LICENSE-2.0" |
---|
13 | __contact__ = "Philip.Kershaw@stfc.ac.uk" |
---|
14 | __revision__ = '$Id: __init__.py 7130 2010-06-30 13:33:07Z pjkersha $' |
---|
15 | import logging |
---|
16 | log = logging.getLogger(__name__) |
---|
17 | |
---|
18 | class SOAPException(Exception): |
---|
19 | """Base SAOP Exception class""" |
---|
20 | |
---|
21 | class SOAPFault(SOAPException): |
---|
22 | """SOAP Fault""" |
---|
23 | |
---|
24 | class SOAPObject(object): |
---|
25 | """Base class for SOAP envelope, header and body elements""" |
---|
26 | |
---|
27 | ELEMENT_PREFIX = "soap11" |
---|
28 | SOAP11_NS = "http://schemas.xmlsoap.org/soap/envelope/" |
---|
29 | SOAP12_NS = "http://www.w3.org/2003/05/soap-envelope" |
---|
30 | DEFAULT_NS = SOAP11_NS |
---|
31 | |
---|
32 | def create(self): |
---|
33 | raise NotImplementedError() |
---|
34 | |
---|
35 | def parse(self): |
---|
36 | raise NotImplementedError() |
---|
37 | |
---|
38 | def serialize(self): |
---|
39 | raise NotImplementedError() |
---|
40 | |
---|
41 | def prettyPrint(self): |
---|
42 | raise NotImplementedError() |
---|
43 | |
---|
44 | |
---|
45 | class SOAPEnvelopeBase(SOAPObject): |
---|
46 | """SOAP Envelope""" |
---|
47 | |
---|
48 | DEFAULT_ELEMENT_LOCAL_NAME = "Envelope" |
---|
49 | DEFAULT_ELEMENT_NS = SOAPObject.DEFAULT_NS |
---|
50 | DEFAULT_ELEMENT_NS_PREFIX = SOAPObject.ELEMENT_PREFIX |
---|
51 | |
---|
52 | soapHeader = property() |
---|
53 | soapBody = property() |
---|
54 | |
---|
55 | |
---|
56 | class SOAPHeaderBase(SOAPObject): |
---|
57 | """SOAP Header base class""" |
---|
58 | |
---|
59 | DEFAULT_ELEMENT_LOCAL_NAME = "Header" |
---|
60 | DEFAULT_ELEMENT_NS = SOAPObject.DEFAULT_NS |
---|
61 | DEFAULT_ELEMENT_NS_PREFIX = SOAPObject.ELEMENT_PREFIX |
---|
62 | |
---|
63 | class SOAPBodyBase(SOAPObject): |
---|
64 | """SOAP Body base class""" |
---|
65 | |
---|
66 | DEFAULT_ELEMENT_LOCAL_NAME = "Body" |
---|
67 | DEFAULT_ELEMENT_NS = SOAPObject.DEFAULT_NS |
---|
68 | DEFAULT_ELEMENT_NS_PREFIX = SOAPObject.ELEMENT_PREFIX |
---|