Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Using Dates & Times

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Hi,

I'm having some difficulty using a Method to provide input to a Reqest via a Form XML window. I'm using the getTime() funciton that was posted on your forum as well as using examples from other folks:

**** Code ****

from java.util import *
from java.text import *

def getTime():
# Get an instance of the calendar
calendar = Calendar.getInstance()

# Set the day in the calendar
day = calendar.get(Calendar.DAY_OF_WEEK)
calendar.set(Calendar.DAY_OF_WEEK, day+1)

# Retreive the date from the calendar
date = calendar.getTime()

# Create the date formatter
# myFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
myFormat = "yyyy-MM-dd'T'00:00:00"
formatter = SimpleDateFormat(myFormat)

# Create, print, and return the timestamp
timestamp = formatter.format(date)
print timestamp
return timestamp

********
I'm trying to set a date field with a data (today+1). Where do I place the method so that I can parameterize the tag?

Robert A. Ramirez
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Have you tried creating a Method Tool before the SOAP Client, and storing the method output to an XML Databank? If you do so, you can parameterize your SOAP Client with the value saved therein.

    To format the output so that the XML Databank can store it, simply replace "return timestamp" with:
    return SOAPUtil.getXMLFromString([timestamp])

    I have included an example .tst file which demonstrates this functionality. Hope this helps.

    Regards,
    Joseph
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Joseph

    I apprieciate the response...works like a charm. Where are you finding the syntax for the additions to the code I posted. Is it standard Python? I would not have know to look for a function "getXMLFromString" in order for this code to work.

    Robert
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    The additional code I added can be found in the SOAtest Scripting API. To access the API, simply go to your SOAtest window and select "Help > Scripting API." It is highly recommended that all SOAtest users take some time to familiarize themselves with the scripting API, as it can prove invaluable in providing scripting solutions to testing setup.

    Regards,
    Joseph