Reputation: 21
I am using Django 1.9 to expose SOAP 1.1 API with Spyne version 2.12.16
I need to implement logging for every request XML and response XML in my platform.
Django urls.py is
url(r'^your_data/', DjangoView.as_view(
name="YourDataService",
services=[YourDataService],
tns='http://127.0.0.1:8000/',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11()))
views.py:
from spyne.decorator import rpc
from spyne.model.primitive import String, AnyDict
from spyne.service import ServiceBase
class YourDataService(ServiceBase):
@rpc(String, String, String, _returns=AnyDict)
def call_this_method(self, a, b, c):
return {'aa': 'OK','bb': 'Great','cc': 'Perfect'}
I read somewhere, overriding call_wrapper method of Spyne ServiceBase class can log request and response XML data for that service. But implementing the same resulted in weird logging etc issues:
class ServiceBaseAbstract(ServiceBase):
def call_wrapper(cls, ctx):
try:
return ctx.service_class.call_wrapper(ctx)
except Exception as err:
print err
It gives an error:
No handlers could be found for logger "spyne.application.server"
API works fine without overriding call_wrapper.
I am really confused and can't find a way out of this. Your help will be much appreciated. Thank you
Upvotes: 2
Views: 475
Reputation: 8011
Overriding call_wrapper
is to alter the way exceptions are handled / logged by Spyne.
Instead, you should configure the python logging library to display DEBUG-level messages and also enable protocol debug logging for Spyne.
logging.getLogger('').setLevel(logging.DEBUG)
logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)
Upvotes: 2