Forum Discussion

manish_singh's avatar
manish_singh
Occasional Contributor
17 years ago

how to disable from xml elements if...

My problem..

Im making test for our webservices.Im doing it with my jdbc datasource .
In my test case
I hav put all the properties from the datasource in my request method.

But some field are optional and for that i put in my corrosponding database fields blanks(null).
When im running the test,At the property where the corrosponding data in null in database, It is sending the ${propery field..} to my request.In my response im getting errors(number format exp or date time exp..)coz it is now seeing the ${property field} instead null.

My Question is How it can be done that elements in the soap request are removed when the corrosponding field is null in database and only request with filled fields proceed???

I think this the the best way to solve this problem(or if there is other way??) but can someone tell how it can be done?

Regards
Manish

4 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Manish,

    hmm.. I think this should be viewed as a bug (ie that the expansion syntax is returned and not an empty string).. can you somehow in your sql-statement add handling of this? (I vaguely remember SQL Server had an ISNULL statement that allowed you to return a default value for null columns)..

    Also, if you dont want the empty elements to show up in your request when there is no value, you may want to extend your select to include the xml-element;

    SELECT "" + name + "" FROM ...

    and in your request replace

    ${DataSource#name}

    with

    ${DataSource#name}

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • manish_singh's avatar
    manish_singh
    Occasional Contributor
    The thing is,I also want that my logic in endpoint will not read that element when it is null or with (${DataSource#name} at present case).

    How that logic can be made that before request is sent to the server ,Data is checked by a logic in SOAPUI and then that XML elements from soap request are disabled when it find (${DataSource#name}).

    FOR example if data contains '$' in xml element then disable it .?

    btw i try what u have said but it would be a long work:-( as my sql statement contain 20 tables with 300 data fields.


    Regards
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    hmm.. you would have to create a groovy script that removes the empty/unwanted elements from the request.. but it is not that easy, since the original request needs to be restored before the next row.. We could add a "remove empty elements" option for outgoing requests that would do just that, which would do what you want.. I'll give it some more thought first..

    regards,

    /Ole
    eviware.com
  • manish_singh's avatar
    manish_singh
    Occasional Contributor
    In between i tried ur option but its not working as..
    made select statement
    select ''+name+'' from table ...
    then in the coloum name its is added ''+name+'' in a same way (not in results) .I add property in datasource the same as the colum ''+name+'' (as it is must otherwise i will not get the value).
    and when i get the null field then it is showing ${''+name+''} so i guess that will not work ..:-(

    If it can be done with groove script then can u clear a bit picture in my mind how it can be done with on field or something like that...

    Regards

    Manish