Python-zeep: NotImplementedError: AnySimpleType.pytonvalue() not implemented

Created on 12 Apr 2017  路  8Comments  路  Source: mvantellingen/python-zeep

While working with an wsdl api, I am having the following error

...
File "c:python34libsite-packageszeep-1.4.1-py3.4.eggzeepxsdtypessimple.py", line 68, in pythonvalue
'%s.pytonvalue() not implemented' % self.class.name)
NotImplementedError: AnySimpleType.pytonvalue() not implemented

Then I looked into the simple.py and it raised this error

def pythonvalue(self, xmlvalue):
raise NotImplementedError(
'%s.pytonvalue() not implemented' % self.class.name)

Wondeing whether there is any fix for this?

Thank you.

requireexample-script

Most helpful comment

I've got the same error on zeep 2.2.0. I doubt if my example code is relevant, because exception happens when I interact with my webcam using onvif based on soap and you probably wouldn't able to reconstruct it. But accordingly to what I've debugged already, exception happens when zeep.xsd.elements.attribute.parse is applied to <tt:SimpleItem Name="Sensitivity" Value="70"/> element of my xml response from webcam (https://www.onvif.org/ver10/schema/onvif.xsd namespace).

Example script:

import zeep
from zeep.wsse.username import UsernameToken
client = zeep.Client('https://www.onvif.org/ver10/media/wsdl/media.wsdl', wsse=UsernameToken('user', 'password', use_digest=True))
service = client.create_service('{http://www.onvif.org/ver10/media/wsdl}MediaBinding', 'http://127.0.0.1:80/onvif/media_service')
service.GetProfiles()

Error traceback traceback.txt

P.S. Changed zeep.xsd.types.simple.AnySimpleType.pythonvalue code to:

def pythonvalue(self, xmlvalue):
    return xmlvalue

and everything is working now. Does this method really should be abstract?

All 8 comments

Hi,

Thanks for the report. It is unfortunately missing an example script as explained in the documentation (see http://docs.python-zeep.org/en/master/reporting_bugs.html). This is also mentioned when you create the issue on github.

I realise this will result in extra work on your side, but I can really use the extra help.

I've got the same error on zeep 2.2.0. I doubt if my example code is relevant, because exception happens when I interact with my webcam using onvif based on soap and you probably wouldn't able to reconstruct it. But accordingly to what I've debugged already, exception happens when zeep.xsd.elements.attribute.parse is applied to <tt:SimpleItem Name="Sensitivity" Value="70"/> element of my xml response from webcam (https://www.onvif.org/ver10/schema/onvif.xsd namespace).

Example script:

import zeep
from zeep.wsse.username import UsernameToken
client = zeep.Client('https://www.onvif.org/ver10/media/wsdl/media.wsdl', wsse=UsernameToken('user', 'password', use_digest=True))
service = client.create_service('{http://www.onvif.org/ver10/media/wsdl}MediaBinding', 'http://127.0.0.1:80/onvif/media_service')
service.GetProfiles()

Error traceback traceback.txt

P.S. Changed zeep.xsd.types.simple.AnySimpleType.pythonvalue code to:

def pythonvalue(self, xmlvalue):
    return xmlvalue

and everything is working now. Does this method really should be abstract?

Is this something to add in a near future?

@mvantellingen I have managed to create example script to get NotImplementedError: AnySimpleType.pytonvalue() not implemented error:

import pretend

from zeep import Client
from zeep.transports import Transport
from zeep.cache import SqliteCache # to workaroud "Remote end closed connection without response" errors

client = Client('https://www.onvif.org/ver10/media/wsdl/media.wsdl',
                transport=Transport(cache=SqliteCache()))
response = pretend.stub(
status_code=200,
headers={},
content=b"""<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema"><s:Header/><s:Body><trt:GetProfilesResponse><trt:Profiles token="MediaProfile000" fixed="true"><tt:Name>MediaProfile_Channel1_MainStream</tt:Name><tt:VideoSourceConfiguration token="000"><tt:Name>VideoSourceConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>000</tt:SourceToken><tt:Bounds x="0" y="0" width="2048" height="1536"/></tt:VideoSourceConfiguration><tt:AudioSourceConfiguration token="000"><tt:Name>AudioSourceConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>000</tt:SourceToken></tt:AudioSourceConfiguration><tt:VideoEncoderConfiguration token="000"><tt:Name>VideoEncoderConfig_Channel1_MainStream</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>H264</tt:Encoding><tt:Resolution><tt:Width>1280</tt:Width><tt:Height>720</tt:Height></tt:Resolution><tt:Quality>6.000000</tt:Quality><tt:RateControl><tt:FrameRateLimit>50</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>2048</tt:BitrateLimit></tt:RateControl><tt:H264><tt:GovLength>50</tt:GovLength><tt:H264Profile>High</tt:H264Profile></tt:H264><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.0.0</tt:IPv4Address></tt:Address><tt:Port>40000</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:AudioEncoderConfiguration token="000"><tt:Name>AudioEncoderConfig_Channel1_MainStream</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>G711</tt:Encoding><tt:Bitrate>128</tt:Bitrate><tt:SampleRate>16</tt:SampleRate><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.0.0</tt:IPv4Address></tt:Address><tt:Port>40002</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:AudioEncoderConfiguration><tt:VideoAnalyticsConfiguration token="000"><tt:Name>VideoAnalyticsConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:AnalyticsEngineConfiguration><tt:AnalyticsModule Name="MyCellMotion" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"/><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="-1.000000"/><tt:Scale x="0.006250" y="0.008340"/></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyTamper" Type="tt:TamperEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="48"/><tt:ElementItem Name="Field"><tt:PolygonConfiguration><tt:Polygon><tt:Point x="0" y="240"/><tt:Point x="0" y="0"/><tt:Point x="320" y="0"/><tt:Point x="320" y="240"/></tt:Polygon></tt:PolygonConfiguration></tt:ElementItem><tt:ElementItem Name="Transformation"><tt:Transformation><tt:Translate x="-1.000000" y="-1.000000"/><tt:Scale x="0.006250" y="0.008340"/></tt:Transformation></tt:ElementItem></tt:Parameters></tt:AnalyticsModule></tt:AnalyticsEngineConfiguration><tt:RuleEngineConfiguration><tt:Rule Name="Region1" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="4"/><tt:SimpleItem Name="AlarmOnDelay" Value="1000"/><tt:SimpleItem Name="AlarmOffDelay" Value="1000"/><tt:SimpleItem Name="ActiveCells" Value="0P8A8A=="/></tt:Parameters></tt:Rule><tt:Rule Name="MyTamperDetector" Type="tt:TamperDetector"><tt:Parameters><tt:ElementItem Name="Field"><tt:PolygonConfiguration><tt:Polygon><tt:Point x="0" y="240"/><tt:Point x="0" y="0"/><tt:Point x="320" y="0"/><tt:Point x="320" y="240"/></tt:Polygon></tt:PolygonConfiguration></tt:ElementItem></tt:Parameters></tt:Rule></tt:RuleEngineConfiguration></tt:VideoAnalyticsConfiguration><tt:PTZConfiguration token="000"><tt:Name>PTZConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:NodeToken>000</tt:NodeToken><tt:DefaultAbsoluteZoomPositionSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace</tt:DefaultAbsoluteZoomPositionSpace><tt:DefaultRelativeZoomTranslationSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace</tt:DefaultRelativeZoomTranslationSpace><tt:DefaultContinuousZoomVelocitySpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace</tt:DefaultContinuousZoomVelocitySpace><tt:DefaultPTZSpeed><tt:Zoom space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" x="0.800000"/></tt:DefaultPTZSpeed><tt:DefaultPTZTimeout>PT10S</tt:DefaultPTZTimeout><tt:ZoomLimits><tt:Range><tt:URI>http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace</tt:URI><tt:XRange><tt:Min>0.000000</tt:Min><tt:Max>1.000000</tt:Max></tt:XRange></tt:Range></tt:ZoomLimits></tt:PTZConfiguration><tt:MetadataConfiguration token="000"><tt:Name>MetadataConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:PTZStatus><tt:Status>false</tt:Status><tt:Position>false</tt:Position></tt:PTZStatus><tt:Events><tt:Filter><wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:RuleEngine/CellMotionDetector/Motion</wsnt:TopicExpression></tt:Filter></tt:Events><tt:Analytics>true</tt:Analytics><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.2.0.0</tt:IPv4Address></tt:Address><tt:Port>40020</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:MetadataConfiguration></trt:Profiles><trt:Profiles token="MediaProfile001" fixed="true"><tt:Name>MediaProfile_Channel1_SubStream1</tt:Name><tt:VideoSourceConfiguration token="000"><tt:Name>VideoSourceConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>000</tt:SourceToken><tt:Bounds x="0" y="0" width="2048" height="1536"/></tt:VideoSourceConfiguration><tt:AudioSourceConfiguration token="000"><tt:Name>AudioSourceConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>000</tt:SourceToken></tt:AudioSourceConfiguration><tt:VideoEncoderConfiguration token="001"><tt:Name>VideoEncoderConfig_Channel1_SubStream1</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>JPEG</tt:Encoding><tt:Resolution><tt:Width>704</tt:Width><tt:Height>576</tt:Height></tt:Resolution><tt:Quality>6.000000</tt:Quality><tt:RateControl><tt:FrameRateLimit>20</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>8192</tt:BitrateLimit></tt:RateControl><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.0.1</tt:IPv4Address></tt:Address><tt:Port>40008</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:AudioEncoderConfiguration token="001"><tt:Name>AudioEncoderConfig_Channel1_SubStream1</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>G711</tt:Encoding><tt:Bitrate>128</tt:Bitrate><tt:SampleRate>16</tt:SampleRate><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.0.1</tt:IPv4Address></tt:Address><tt:Port>40010</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:AudioEncoderConfiguration><tt:VideoAnalyticsConfiguration token="000"><tt:Name>VideoAnalyticsConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:AnalyticsEngineConfiguration><tt:AnalyticsModule Name="MyCellMotion" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="60"/><tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="18"><tt:Transformation><tt:Translate x="-1.000000" y="-1.000000"/><tt:Scale x="0.006250" y="0.008340"/></tt:Transformation></tt:CellLayout></tt:ElementItem></tt:Parameters></tt:AnalyticsModule><tt:AnalyticsModule Name="MyTamper" Type="tt:TamperEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="48"/><tt:ElementItem Name="Field"><tt:PolygonConfiguration><tt:Polygon><tt:Point x="0" y="240"/><tt:Point x="0" y="0"/><tt:Point x="320" y="0"/><tt:Point x="320" y="240"/></tt:Polygon></tt:PolygonConfiguration></tt:ElementItem><tt:ElementItem Name="Transformation"><tt:Transformation><tt:Translate x="-1.000000" y="-1.000000"/><tt:Scale x="0.006250" y="0.008340"/></tt:Transformation></tt:ElementItem></tt:Parameters></tt:AnalyticsModule></tt:AnalyticsEngineConfiguration><tt:RuleEngineConfiguration><tt:Rule Name="Region1" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="4"/><tt:SimpleItem Name="AlarmOnDelay" Value="1000"/><tt:SimpleItem Name="AlarmOffDelay" Value="1000"/><tt:SimpleItem Name="ActiveCells" Value="0P8A8A=="/></tt:Parameters></tt:Rule><tt:Rule Name="MyTamperDetector" Type="tt:TamperDetector"><tt:Parameters><tt:ElementItem Name="Field"><tt:PolygonConfiguration><tt:Polygon><tt:Point x="0" y="240"/><tt:Point x="0" y="0"/><tt:Point x="320" y="0"/><tt:Point x="320" y="240"/></tt:Polygon></tt:PolygonConfiguration></tt:ElementItem></tt:Parameters></tt:Rule></tt:RuleEngineConfiguration></tt:VideoAnalyticsConfiguration><tt:PTZConfiguration token="000"><tt:Name>PTZConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:NodeToken>000</tt:NodeToken><tt:DefaultAbsoluteZoomPositionSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace</tt:DefaultAbsoluteZoomPositionSpace><tt:DefaultRelativeZoomTranslationSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace</tt:DefaultRelativeZoomTranslationSpace><tt:DefaultContinuousZoomVelocitySpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace</tt:DefaultContinuousZoomVelocitySpace><tt:DefaultPTZSpeed><tt:Zoom space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" x="0.800000"/></tt:DefaultPTZSpeed><tt:DefaultPTZTimeout>PT10S</tt:DefaultPTZTimeout><tt:ZoomLimits><tt:Range><tt:URI>http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace</tt:URI><tt:XRange><tt:Min>0.000000</tt:Min><tt:Max>1.000000</tt:Max></tt:XRange></tt:Range></tt:ZoomLimits></tt:PTZConfiguration><tt:MetadataConfiguration token="000"><tt:Name>MetadataConfig_Channel1</tt:Name><tt:UseCount>2</tt:UseCount><tt:PTZStatus><tt:Status>false</tt:Status><tt:Position>false</tt:Position></tt:PTZStatus><tt:Events><tt:Filter><wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:RuleEngine/CellMotionDetector/Motion</wsnt:TopicExpression></tt:Filter></tt:Events><tt:Analytics>true</tt:Analytics><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.2.0.0</tt:IPv4Address></tt:Address><tt:Port>40020</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:MetadataConfiguration></trt:Profiles></trt:GetProfilesResponse></s:Body></s:Envelope>""")

service = client.create_service('{http://www.onvif.org/ver10/media/wsdl}MediaBinding', 'http://127.0.0.1/onvif/media_service')
operation = service._binding._operations['GetProfiles']

#operation = client.service._binding._operations['GetProfiles']
#result = client.service._binding.process_reply(client, operation, response)

result = service._binding.process_reply(client, operation, response)

print(result)

Please un-close bug report :)

The problem exists, I confirm it.

I have the same problem

I also have this problem

I am also having this problem. @MikhailLychagin's workaround works for me as well. This seems very similar to #644 with a similar fix of removing the pythonvalue override in zeep.xsd.types.simple.AnySimpleType:

    def pythonvalue(self, xmlvalue):
        raise NotImplementedError(
            "%s.pytonvalue() not implemented" % self.__class__.__name__
        )

This would cause zeep.xsd.types.any.AnyType's pythonvalue to be used:

    def pythonvalue(self, value, schema=None):
        return value

Which is basically what @MikhailLychagin's workaround does.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhinchakdhoom picture dhinchakdhoom  路  4Comments

ri8on picture ri8on  路  4Comments

allan-simon picture allan-simon  路  4Comments

alexdemari picture alexdemari  路  4Comments

pope1ni picture pope1ni  路  4Comments