python-zeep
python-zeep copied to clipboard
Plugins.apply_ingress didn't work when Settings set raw_response=True
Hi, I'm using Zeep 4.10 that found a bug(I think) The WSDL is from the zeep docs : http://www.soapclient.com/xml/soapresponder.wsdl here is my script
import time
from datetime import datetime
from zeep import Plugin, Settings, Client
class MyPlugin(Plugin):
def egress(self, envelope, http_headers, operation, binding_options):
self.start_time = time.time()
print(f"{self.__class__.__name__} star_time is {datetime.now()}")
return envelope, http_headers
def ingress(self, envelope, http_headers, operation):
cost_time = time.time() - self.start_time
print(f"{self.__class__.__name__} cost_time is {cost_time:.2f}")
return envelope, http_headers
wsdl = 'http://www.soapclient.com/xml/soapresponder.wsdl'
settings = Settings(raw_response=True)
# settings = Settings(raw_response=False)
client = Client(wsdl=wsdl, settings=settings, plugins=[MyPlugin()])
response = client.service.Method1('Zeep', 'is cool')
if isinstance(response, str):
print(response)
else:
print(response.status_code)
And here is what I get: MyPlugin star_time is 2021-09-09 22:11:19.241122 200
And I dig into source code found that apply_ingress
called by process_reply
but when raw_response=True
will return before call process_reply
so there no change to call apply_ingress