Fixed some type mismatches in case when mtom/xop is in incoming message#716
Fixed some type mismatches in case when mtom/xop is in incoming message#716shasoka wants to merge 1 commit into
Conversation
UPD: Found the source of HTTP 500 for mp3 and other "usually-huge" files. # server/main.py
import logging
import sys
from spyne import Application, Fault, InternalError, ResourceNotFoundError
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from sqlalchemy.exc import NoResultFound
from twisted.internet import reactor
from twisted.python import log
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
from core.config import MAIN_TNS
from core.db.defctx import on_method_call
from services.files import FileService
from services.users import UserService
class MyApplication(Application):
def __init__(
self, services, tns, name=None, in_protocol=None, out_protocol=None
):
super().__init__(services, tns, name, in_protocol, out_protocol)
def call_wrapper(self, ctx):
try:
return ctx.service_class.call_wrapper(ctx)
except NoResultFound as e:
log.msg("[EXCEPTION] " + e)
raise ResourceNotFoundError(ctx.in_object)
except Fault as e:
log.msg("[EXCEPTION] " + e)
raise
except Exception as e:
log.msg("[EXCEPTION] " + e)
raise InternalError(e)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
observer = log.PythonLoggingObserver("twisted")
log.startLogging(sys.stdout)
application = MyApplication(
[UserService, FileService],
tns=MAIN_TNS,
in_protocol=Soap11(validator="lxml"),
out_protocol=Soap11(),
)
application.event_manager.add_listener("method_call", on_method_call)
wsgi_app = WsgiApplication(
application,
max_content_length=10 * 1024 * 1024,
)
resource = WSGIResource(reactor, reactor, wsgi_app)
site = Site(resource)
reactor.listenTCP(8000, site, interface="127.0.0.1") # noqa
log.msg("🧼 Listening to http://127.0.0.1:8000")
log.msg("📝 WSDL is at http://127.0.0.1:8000/?wsdl")
sys.exit(reactor.run()) # noqa |
I'm building simple SOAP-service with
Spyne 2.14and a SOAP-client withZeep 4.3.1+pymtom_xop 0.0.2onPython 3.10as part of my university's homework.I've faced the problem using
Spynefor handling incomingMTOM/XOPattachments. There were multiple not handled exceptions, generally because of types mismatching and not-declared variables. I'm wondering how linter skipped such mistakes, anyways...I tried my best to catch and handle them, so now it works almost fine. I still receive HTTP 500 for mp3 files (yeah, very strange), but for now I'll leave it as is 🫤