need help in adding timestanp zeep wsse - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: need help in adding timestanp zeep wsse (/thread-13933.html) |
need help in adding timestanp zeep wsse - sachingle - Nov-07-2018 Hi Guys, I am working on code consume a SOAP web service using zeep client. I need to pass wsse username token as well as Timestap to this webservice but i am not able add time stamp. from datetime import datetime from datetime import timedelta from zeep import Client from zeep.wsse import UsernameToken #username_token=UsernameToken('username', 'Welcome.1') #Timestamp_token=Timestamp(Created=datetime.now(),Expires=datetime.now()+timedelta(days=1)) url="https://ss/esswebservice?WSDL" client = Client(url,wsse=[UsernameToken('shmadan', 'Welcome.1'),timestamp(Created=datetime.now(),Expires=datetime.now()+timedelta(days=1))]) result = client.service.submitInstantRecurringRequest(description='TestESS1',jobDefinitionId = { 'name': 'BulkImportJob', 'packageName': '/oracle/apps/ess/cdm/foundation/bulkImport/', 'type': 'JOB_DEFINITION' } ,iCalSchedule='FREQ=DAILY;INTERVAL=2;',application='CrmEss',requestedStartTime=datetime.now(),requestedEndTime=datetime.now()+timedelta(days=1), requestParameters={} ) print (result) ## shows the details of this service
RE: need help in adding timestanp zeep wsse - buran - Nov-07-2018 Do you have docs on the format expected (i.e. timestamp in particular)? RE: need help in adding timestanp zeep wsse - sachingle - Nov-07-2018 Hi Buran, following is the python code used but it gives "The security token is not valid." error The webservice accepts Timestamp as part of the security tocken I have searched zeep dicumentation but there is no mention of the wsse Timestamp token from datetime import datetime from datetime import timedelta from zeep import Client from zeep.wsse import UsernameToken from lxml import etree from zeep.wsse import utils #username_token=UsernameToken('usernmae', 'Welcome.1') #Timestamp_token=Timestamp(Created=datetime.now(),Expires=datetime.now()+timedelta(days=1)) url="/esswebservice?WSDL" client = Client(url,wsse=UsernameToken('username', 'Welcome.1')) result = client.service.submitInstantRecurringRequest(description='TestESS1',jobDefinitionId = { 'name': 'BulkImportJob', 'packageName': '/oracle/apps/ess/cdm/foundation/bulkImport/', 'type': 'JOB_DEFINITION' } ,iCalSchedule='FREQ=DAILY;INTERVAL=2;',application='CrmEss',requestedStartTime=datetime.now(),requestedEndTime=datetime.now()+timedelta(days=1), requestParameters={} ) print (result) ## shows the details of this service RE: need help in adding timestanp zeep wsse - buran - Nov-07-2018 Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you in your previous post. See BBcode help for more info. The time stamp format will be specified in the docs for the service, not the zeep client. e.g. it may require timestamp in UTC, in some predefined format, etc. |