question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with GetSreamUri Function: No namespace defined for 'ter'

See original GitHub issue

Hello Guys I get this error when I try to run the function GetStreamUri:

  File "/usr/local/lib/python3.5/dist-packages/onvif_zeep-0.2.12-py3.5.egg/onvif/client.py", line 23, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/onvif_zeep-0.2.12-py3.5.egg/onvif/client.py", line 153, in wrapped
    return call(params, callback)
  File "/usr/local/lib/python3.5/dist-packages/onvif_zeep-0.2.12-py3.5.egg/onvif/client.py", line 140, in call
    ret = func(**params)
  File "/usr/local/lib/python3.5/dist-packages/zeep-3.1.0-py3.5.egg/zeep/proxy.py", line 42, in __call__
    self._op_name, args, kwargs)
  File "/usr/local/lib/python3.5/dist-packages/zeep-3.1.0-py3.5.egg/zeep/wsdl/bindings/soap.py", line 132, in send
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.5/dist-packages/zeep-3.1.0-py3.5.egg/zeep/wsdl/bindings/soap.py", line 194, in process_reply
    return self.process_error(doc, operation)
  File "/usr/local/lib/python3.5/dist-packages/zeep-3.1.0-py3.5.egg/zeep/wsdl/bindings/soap.py", line 338, in process_error
    subcode_qname = as_qname(subcode_value_element.text, subcode_value_element.nsmap, None)
  File "/usr/local/lib/python3.5/dist-packages/zeep-3.1.0-py3.5.egg/zeep/utils.py", line 31, in as_qname
    "No namespace defined for %r (%r)" % (prefix, value))
zeep.exceptions.XMLParseError: No namespace defined for 'ter' ('ter:InvalidArgVal')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "testcam.py", line 32, in <module>
    print(media_service.GetStreamUri(obj))
  File "/usr/local/lib/python3.5/dist-packages/onvif_zeep-0.2.12-py3.5.egg/onvif/client.py", line 26, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: No namespace defined for 'ter' ('ter:InvalidArgVal')

Here is the funtion I am running:

from onvif import ONVIFCamera, ONVIFService

 mycam = ONVIFCamera('192.168.0.112', 80, 'admin', '12345')
 media_service = mycam.create_media_service()
 profiles = media_service.GetProfiles()
 token = profiles[0].token         // using attribute '_token' returns and error so I am using atribute 'token'

obj = media_service.create_type('GetStreamUri')
obj.ProfileToken = token
obj.StreamSetup = {'Stream': 'RTP-Unicast', 'Transport': {'Protocol': 'RTSP'}}
print(media_service.GetStreamUri(obj))

The error occurs on the funtion: ##obj = media_service.create_type(‘GetStreamUri’)

I have tried installing using pip3 and I have also tried installing from the github repo. I have also checkout different versions of the github repo, but all give the same error.

Any help will be appreciated, thanks, @FalkTannhaeuser @sinchb @iomihai @mpromonet @eLvErDe

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
hubuguicommented, May 7, 2019

I write a simple base on example/streaming.py and python-onvif-zeep/issues/4, it work nice with HiKvision camera, as follow:

import zeep
from onvif import ONVIFCamera, ONVIFService

def zeep_pythonvalue(self, xmlvalue):
    return xmlvalue

zeep.xsd.simple.AnySimpleType.pythonvalue = zeep_pythonvalue

def media_profile_configuration():
    '''
    A media profile consists of configuration entities such as video/audio
    source configuration, video/audio encoder configuration,
    or PTZ configuration. This use case describes how to change one
    configuration entity which has been already added to the media profile.
    '''

    # Create the media service
    mycam = ONVIFCamera('192.168.5.248', 80, 'admin', 'xxxxxx', 'E://python-onvif-zeep/wsdl/')
    media_service = mycam.create_media_service()

    token = None
    profiles = media_service.GetProfiles()
    print("dump profiles and find first profile token")
    for prof in profiles:
        if not token:
            token = prof["token"]
            print(token)

    # Use the first profile and Profiles have at least one
    # token = profiles[0]._token
    token = "Profile_1"

    # Get all video encoder configurations
    configurations_list = media_service.GetVideoEncoderConfigurations()
    print("dump configuration list")
    for config in configurations_list:
        print(config)

    obj = media_service.create_type('GetStreamUri')
    obj.ProfileToken = token
    obj.StreamSetup = {'Stream': 'RTP-Unicast', 'Transport': {'Protocol': 'RTSP'}}
    print("dump stream uri")
    print(media_service.GetStreamUri(obj))

if __name__ == '__main__':
    media_profile_configuration()
0reactions
ashish1405commented, Sep 11, 2020

I know this is old, but if anyone faces this issue, try to replace the code in client.py - ONVIFService - __init__ From

       self.create_type = lambda x: self.zeep_client.get_element('ns0:' + x)()

to

        namespace = binding_name[binding_name.find("{") + 1 : binding_name.find("}")]
        available_ns = self.zeep_client.namespaces
        active_ns = (
            list(available_ns.keys())[list(available_ns.values()).index(namespace)]
            or "ns0"
        )
        self.create_type = lambda x: self.zeep_client.get_element(active_ns + ":" + x)()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Function definition not found for a function declared inside ...
The problem is that the declarations in the unnamed namespace do not declare the same functions that you later define in the global ......
Read more >
Argument-dependent lookup - cppreference.com
Argument-dependent lookup, also known as ADL, or Koenig lookup, is the set of rules for looking up the unqualified function names in ...
Read more >
Do not define an unnamed namespace in a header file
Unnamed namespaces are used to define a namespace that is unique to the translation unit, where the names contained within have internal linkage...
Read more >
LLVM Coding Standards — LLVM 16.0.0git documentation
Treat Compiler Warnings Like Errors; Write Portable Code; Do not use RTTI or ... Use Namespace Qualifiers to Implement Previously Declared Functions ......
Read more >
7 Environments | Advanced R - Hadley Wickham
There's no direct link between the package and namespace environments; the link is defined by the function environments. 7.4.4 Execution environments. The last ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found