feat(client, operator): add XML capture plugin for SOAP request/respo… · nirsimetri/onvif-python@c258162 · GitHub
Skip to content

Commit c258162

Browse files
committed
feat(client, operator): add XML capture plugin for SOAP request/response logging
1 parent c176715 commit c258162

6 files changed

Lines changed: 126 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion

README_ID.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Beberapa layanan ONVIF memiliki banyak binding dalam WSDL yang sama. Biasanya me
323323
- [ ] Mengimplementasikan model data terstruktur untuk Skema ONVIF menggunakan [xsdata](https://github.com/tefra/xsdata).
324324
- [ ] Integrasi [xmltodict](https://github.com/martinblech/xmltodict) untuk parsing dan konversi XML yang lebih sederhana.
325325
- [ ] Menambahkan kemampuan agar `ONVIFClient` menerima layanan `wsdl_path` kustom.
326-
- [ ] Menambahkan mode debugging dengan raw XML pada permintaan dan respons SOAP.
326+
- [x] Menambahkan mode debugging dengan raw XML pada permintaan dan respons SOAP.
327327
- [ ] Meningkatkan dokumentasi dengan referensi API dan diagram (bukan dari [AI Wiki](https://deepwiki.com/nirsimetri/onvif-python)).
328328
- [ ] Menambah lebih banyak contoh penggunaan untuk fitur lanjutan.
329329
- [ ] Menambah benchmarking dan metrik performa.

onvif/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
remove_patch as _remove_zeep_patch,
4747
)
4848
from .utils.wsdl import ONVIFWSDL
49+
from .utils.xml_capture import XMLCapturePlugin
4950

5051

5152
class ONVIFClient:
@@ -60,6 +61,7 @@ def __init__(
6061
use_https=False,
6162
verify_ssl=True,
6263
apply_patch=True,
64+
capture_xml=False,
6365
):
6466
self.apply_patch = apply_patch
6567

@@ -69,6 +71,12 @@ def __init__(
6971
else:
7072
_remove_zeep_patch()
7173

74+
# Initialize XML capture plugin if requested
75+
self.xml_plugin = None
76+
if capture_xml:
77+
self.xml_plugin = XMLCapturePlugin()
78+
79+
# Pass to ONVIFOperator
7280
self.common_args = {
7381
"host": host,
7482
"port": port,
@@ -78,7 +86,8 @@ def __init__(
7886
"cache": cache,
7987
"use_https": use_https,
8088
"verify_ssl": verify_ssl,
81-
"apply_flatten": apply_patch, # Pass to ONVIFOperator
89+
"apply_flatten": apply_patch,
90+
"plugins": [self.xml_plugin] if self.xml_plugin else None,
8291
}
8392

8493
# Device Management (Core) service is always available

onvif/operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(
5353
use_https: bool = False,
5454
verify_ssl: bool = True,
5555
apply_flatten: bool = True,
56+
plugins: list = None,
5657
):
5758
self.wsdl_path = wsdl_path
5859
self.host = host
@@ -109,6 +110,7 @@ def __init__(
109110
transport=transport,
110111
settings=settings,
111112
wsse=wsse,
113+
plugins=plugins,
112114
)
113115

114116
if not binding:

onvif/utils/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .wsdl import ONVIFWSDL
22
from .exceptions import ONVIFOperationException
3+
from .xml_capture import XMLCapturePlugin
34

4-
__all__ = ["ONVIFWSDL", "ONVIFOperationException"]
5+
__all__ = ["ONVIFWSDL", "ONVIFOperationException", "XMLCapturePlugin"]

onvif/utils/xml_capture.py

Lines changed: 110 additions & 0 deletions

0 commit comments

Comments
 (0)