Skip to content

Instantly share code, notes, and snippets.

@raiever
Last active March 10, 2020 13:37
Show Gist options
  • Save raiever/dc2898d0acc3966fe640111f1393081a to your computer and use it in GitHub Desktop.
Save raiever/dc2898d0acc3966fe640111f1393081a to your computer and use it in GitHub Desktop.
ONVIF test using zeep
from zeep.client import Client, CachingClient, Settings
from zeep.wsse.username import UsernameToken
import zeep.helpers
import logging.config
# Put Zeep into verbose mode
logging.config.dictConfig({
'version': 1,
'formatters': {
'verbose': {
'format': '%(name)s: %(message)s'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'zeep.transports': {
'level': 'DEBUG',
'propagate': True,
'handlers': ['console'],
},
}
})
ip="192.168.2.195"; user="admin"; passwd="H*******"; port=80
settings = Settings()
settings.strict = False
settings.xml_huge_tree = True
# WSDL File
url = "https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl"
# *** Devicemgmt Service ***
xaddr = "http://"+ip+"/onvif/device_service"
print("creating a soap client with url = ", url)
zeep_client_device = CachingClient(wsdl=url, wsse=UsernameToken(user, passwd, use_digest=True), settings=settings)
print("soap client created")
print("binding to service")
ws_client_device = zeep_client_device.create_service("{http://www.onvif.org/ver10/device/wsdl}DeviceBinding", xaddr)
print("service OK")
ws_client_device.GetCapabilities(Category='Device')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment