Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
handle zsi.fault
Browse files Browse the repository at this point in the history
  • Loading branch information
jfroche committed Dec 17, 2008
1 parent 5ac9b4c commit 646e8db
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.3 - (2008-12-17)
------------------

∗ Handle correclty ZSI.Fault exception

0.2 - (2008-11-14)
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '0.2'
version = '0.3'

setup(name='z3c.soap',
version=version,
Expand Down
36 changes: 35 additions & 1 deletion z3c/soap/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This package is largely inspired from Zope 3 SOAP (http://svn.zope.org/soap).

Let's write a simple SOAP view that echoes various types of input:

>>> import ZSI
>>> from Products.Five import BrowserView
>>> class EchoView(BrowserView):
...
Expand Down Expand Up @@ -62,6 +63,10 @@ Let's write a simple SOAP view that echoes various types of input:
... mail = requestData._Email
... response._Status = '%s is OK' % mail
... return response
...
... def testFault(self):
... raise ZSI.Fault(ZSI.Fault.Client, "Testing the zsi fault")



Now we'll register it as a SOAP view. For now we'll just register the
Expand All @@ -86,7 +91,8 @@ view for folder objects and call it on the root folder:
... for="OFS.interfaces.IFolder"
... methods="echoString echoStringArray echoInteger echoIntegerArray
... echoFloat echoFloatArray echoStruct echoVoid echoBase64
... echoDate echoDecimal echoBoolean ValidateEmailRequest"
... echoDate echoDecimal echoBoolean ValidateEmailRequest
... testFault"
... class="z3c.soap.README.EchoView"
... permission="zope2.SOAPAccess"
... />
Expand Down Expand Up @@ -615,6 +621,34 @@ directly. Either case causes a fault response to be returned:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Processing Failure</faultstring><detail><ZSI:FaultDetail><ZSI:string>
...

Here is a ZSI Fault response:

>>> print http(r"""
... POST /test_folder_1_ HTTP/1.0
... Authorization: Basic %s:%s
... Content-Length: 104
... Content-Type: text/xml
... SOAPAction: /
...
... <?xml version="1.0"?>
... <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/"
... xmlns:xsd="http://www.w3.org/2001/XMLSchema"
... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
... <SOAP-ENV:Body>
... <m:testFault xmlns:m="http://www.soapware.org/">
... </m:testFault>
... </SOAP-ENV:Body>
... </SOAP-ENV:Envelope>
... """ % (user_name, user_password), handle_errors=True)
HTTP/1.0 200 OK
Content-Length: 488
Content-Type: text/xml
<BLANKLINE>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Testing the zsi fault</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>


Complex Types
-------------
Expand Down
2 changes: 1 addition & 1 deletion z3c/soap/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

security.declarePublic('SOAP Access')
SoapAccess = 'SOAP Access'
setDefaultRoles(SoapAccess, ('Authenticated', ))
setDefaultRoles(SoapAccess, ('Manager', ))
2 changes: 1 addition & 1 deletion z3c/soap/soap.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def exception(self, fatal=0, info=None,
content = "".join(traceback.format_tb(tb))
logger = logging.getLogger('Zope')
logger.info('SOAPException: %s' % content)
f=None
f=v
if t == 'Unauthorized' or t == Unauthorized or (
isinstance(t, types.ClassType) and issubclass(t, Unauthorized)):
self._real.setStatus(401)
Expand Down

0 comments on commit 646e8db

Please sign in to comment.