Python Forum
need help in adding timestanp zeep wsse
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help in adding timestanp zeep wsse
#1
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
Output:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsu:Timestamp wsu:Id="TS-C2F459A7D74D7BCA9A15415793751764"> <wsu:Created>2018-11-07T08:29:35.176Z</wsu:Created> <wsu:Expires>2018-11-07T08:30:35.176Z</wsu:Expires> </wsu:Timestamp> <wsse:UsernameToken wsu:Id="UsernameToken-C2F459A7D74D7BCA9A15415793692663"> <wsse:Username>username</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Welcome.1</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">dCRbKR1kKJOfmrMS+IgKbw==</wsse:Nonce> <wsu:Created>2018-11-07T08:29:29.266Z</wsu:Created> </wsse:UsernameToken> </wsse:Security>
Reply
#2
Do you have docs on the format expected (i.e. timestamp in particular)?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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
Reply
#4
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Zeep AWS problem centorillion 2 1,789 Nov-10-2022, 09:36 PM
Last Post: Larz60+
  Python zeep offline installation on RHEL akinmhmt 0 1,990 Mar-26-2020, 09:04 AM
Last Post: akinmhmt
  Adding markers to Folium map only adding last element. tantony 0 2,119 Oct-16-2019, 03:28 PM
Last Post: tantony
  Zeep lib, encrypt soap body miha1234 0 2,839 Sep-12-2019, 07:52 AM
Last Post: miha1234

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020