Forum Discussion

Michael_Heinze's avatar
Michael_Heinze
Contributor
15 years ago

[SOLVED]import empty datetime from datasource problem

hi,

in our app we have daylight savings where we either import a datetime or just the month, week, day. so when i enter the month,... i need to leave the datetime empty. this works fine as long as i use a soapui teststep. but when i try to import the empty datetime value from excel i am getting an error:
The string '' is not a valid AllXsd value.

i also tried to create a property expansion variable with nothing entered but get the same error.

i cannot use the remove empty content setting in the teststep as this removes other fields which are needed in the wsdl but have no nodes.

is there a way to change the datetime field from this:

     
     3
     
      Third
       Sunday


to use nil and not empty:

     
     3
     
      Third
       Sunday


thanks

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello!

    If I understand you correctly, importing the empty value from excel causes an empty value to be sent, instead of a null value, which is what you need it to send?

    If so, you can replace the empty element with a null value using an Event Handler.

    Go into the "Events" tab in the main Project window and add a new handler for RequestFilter.filterRequest. Either leave the "Target" field empty for this to run on all requests, or specify the name of a TestStep for it to run only on that one TestStep.

    Then enter the following script:


    context.requestContent = context.requestContent.replace('<het4:Date></het4:Date>', '<het4:Date xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>')


    which will do a simple string replace on the request content right before it is sent. If this particular element is empty, it will replace it with a null value (you could also strip it out entirely if you wanted). Hope this is what you needed! Good luck!

    Regards,
    Dain
    eviware.com