Python-zeep: Any way to ignore/avoid "got an unexpected keyword argument" exceptions

Created on 18 Jul 2017  路  3Comments  路  Source: mvantellingen/python-zeep

I'm going to describe my issue as best as I can, sorry if it's not really clear,

I've been stuck for hours. Is there any way I can call a service operation with keyword arguments that aren't in it's signature? Doesn't matter if they're stripped away.

I have a case where I need to call a service method, say my_service_method(a1, a2, a3)
Given there's a non-critical warning on server's side, I receive a payload that contain the args I originally sent, and I need to recall the method with the same args, to basically tell the server "ignore this warning"

Problem is, the args array also contains args that weren't in the original call, and that aren't in the method's signature. These "new" args vary from a method to another, so I can't just do an hardcoded strip of the new args.

So, my payload on returns for example could contain,
a1=x
a2=y
a3=z
a4=c
a5=d
a6=e

The new args don't necessarily need to be sent, so I don't mind if there's a way to just strip them away (basically strip away any unexpected keyword argument)

Traceback (most recent call last):
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packageehave\model.py", line 1456, in run
          match.run(runner.context)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packageehave\model.py", line 1903, in run
          self.func(context, *args, **kwargs)
        File "D:\PYTHON\saas-gsked      ests\lib\step_parser.py", line 208, in step_implementation
          context.keywords.have(entity, **args)
        File "d:\python\saas-gsked      ests\lib\keywords.py", line 231, in have
          self.create(entity, **original_params)
        File "d:\python\saas-gsked      ests\lib\keywords.py", line 55, in create
          code, payload = self.behave_context.api.call_method(method, **args)
        File "d:\python\saas-gsked      ests\libpi.py", line 161, in call_method
          response = self.client.service[method](self.token, **payload['validation']['args'])
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep\client.py", line 41, in __call__
          self._op_name, args, kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep\wsdindings\soap.py", line 110, in send
          options=options)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep\wsdindings\soap.py", line 68, in _create
          serialized = operation_obj.create(*args, **kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep\wsdl\definitions.py", line 197, in create
          return self.input.serialize(*args, **kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep\wsdl\messages\soap.py", line 64, in serialize
          body_value = self.body(*args, **kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep麓鈹惵d\elements\element.py", line 48, in __call__
          instance = self.type(*args, **kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep麓鈹惵d   ypes\complex.py", line 42, in __call__
          return self._value_class(*args, **kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep麓鈹惵d
                                                                                           alueobjects.py", line 89, in __init__
          items = _process_signature(self._xsd_type, args, kwargs)
        File "c:麓鈹惵ers\olivier.verville\envs\garda-gsked\lib\site-packages\zeep麓鈹惵d
                                                                                           alueobjects.py", line 226, in _process_signature
          xsd_type.signature(standalone=False)))
      TypeError: {garda.gsked.v1.soap}create_contract_req() got an unexpected keyword argument u'event_action_id'. Signature: `token: {spyne.model.primitive.string}MandatoryString, company_id: {spyne.model.primitive.string}MandatoryString, type: xsd:string, status: xsd:string, description: xsd:string, client_purchase_order: xsd:string, start
_date: xsd:date, end_date: xsd:date, renewal_date: xsd:date, annotation: xsd:string, confirm_token: xsd:string
requireexample-script

Most helpful comment

@olivierverville what is the workaround ?

All 3 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 ended up finding another way which didn't require any workaround to get past this issue, which wasn't really an issue but rather the result of using this SOAP client in a very unconventional and dynamic way. The workaround I ended up using is better anyways.

Really loving Zeep btw, thanks.

@olivierverville what is the workaround ?

Was this page helpful?
0 / 5 - 0 ratings