I am making a SOAP call via Zeep and utilizing the plugin based on the documentation located here. The class is defined as a variable plugin
which is then sent in the Client
. When I run resp = service.listChange()
it will run the class ResponseHeader
which prints the following:
Headers:
{'Set-Cookie': 'JSESSIONIDSSO=F8C6115A5588CD010C4A646A0751C2C3; Path=/; Secure; HttpOnly, JSESSIONID=B8B5AB8ACB982C021F1E94DC23F12A6A; Path=/axl; Secure; HttpOnly',
'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'Content-Security-Policy': "default-src *; script-src * 'unsafe-inline' 'unsafe-eval';style-src * 'unsafe-inline'; img-src * data: 'unsafe-inline';", 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Content-Type': 'text/xml;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Date': 'Thu, 22 Jun 2023 12:36:07 GMT', 'Server': ''}
Instead of printing I need to be able to access the http_headers
variable that is returned from service.listChange()
class ResponseHeader( Plugin ):
def ingress( self, envelope, http_headers, operation ):
print( f'\nResponse\n-------\nHeaders:\n{http_headers}\n' )
session = Session()
session.verify = False
urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning
session.auth = HTTPBasicAuth(username, password)
transport = Transport( session = session, timeout = 10 )
settings = Settings(xml_huge_tree = True )
plugin = [ ResponseHeader() ] if DEBUG else []
client = Client( WSDL_FILE, settings = settings, transport = transport, plugins = plugin )
service = client.create_service( '{http://www.cisco.com/AXLAPIService/}AXLAPIBinding',
'https://server:8443/axl/' )
try:
resp = service.listChange()
header = ResponseHeader()
print(header)
except Exception as err:
logging.error( f'\nZeep error: initial listChange: { err }' )
sys.exit( 1 )
I have also tried defining `http_headers` outside of the class which did not work either.