IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Hide empty or null fields

  • 1.  Hide empty or null fields

    Posted Tue April 12, 2016 10:29 AM

    Hi,

    I’ve recreated a new webMethods web service based on a previous ESB Sonic web service.

    All works well, except that with the new webservice, null fields are returned in the Response (with the previous web service, the null value fields were hidden, and we need the same working as before).

    How may I make some null fields hidden with webMethods please ?
    I have tried setting “Allow = True” and “Required = false” but the field is returning anyway in the response Document.

    Regards

    (I would appreciate to not have to change my mapping, testing value of the fields, etc…)


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Hide empty or null fields

    Posted Tue April 12, 2016 01:50 PM

    or maybe it is impossible to hide it with webMethods ?


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: Hide empty or null fields

    Posted Tue April 12, 2016 02:28 PM

    Hi Cedric,

    as long as a field is explicitly mapped (either by setting a value directly or by mapping) it will exist in the target structure.

    When using mappings and the value does not exist on the source or is explicitly presented as empty, the target will have an empty field.

    To avoid this you will have to test the field for emptyness and only map when it has a content.

    This can be either done by Copy Conditions or by explictly branching of the field and check for $null (missing field) and “” (empty field).

    Maybe there is an option use some sort of regex or a XSLT transformation to remove the empty fields after the mapping is finished.

    Regards,
    Holger


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: Hide empty or null fields

    Posted Tue April 12, 2016 10:07 PM

    We can write a java code to get IData as input and recursively remove all null or empty fields and call it in end of the flow service.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 05:02 AM

    Thanks… but I was thinking that the Designer could bring me a solution (a kind of attribute field).

    Yes Venkata you’re right, I was considering to code that in Java (I didn’t see any other solution) because on some web services I have almost 500 concerned fields… :cry:

    but I was hesitating between filling the null value with empty string… or just remove the fields…

    Regards


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 6.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 08:59 AM

    Hum… and in Java, how may I know if a field is “Required”, “Allow null” please ?


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 7.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 09:14 AM

    I thought Ur initial requirement is to remove null fields in Response.

    "
    I’ve recreated a new webMethods web service based on a previous ESB Sonic web service.

    All works well, except that with the new webservice, null fields are returned in the Response (with the previous web service, the null value fields were hidden, and we need the same working as before).
    "


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 09:17 AM

    Yes, you’re right I’m going to remove the null fields.

    but is there any way to test if that field si “required” or “allow null” before to remove it ?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 9.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 09:19 AM

    I think the web service schema validations will throw errors if its required field


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 09:30 AM

    Ok I see. so if the field is not required, the removing will work well, otherwise the Exception will occur in webMethods ?

    In addition, I’m just curious to know how to retrieve these informations for a more general need…
    maybe it will help me, one day ?
    is there any function for this kind of options ? ( getOptions(IData) )

    Regards


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 11.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 09:40 AM


  • 12.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 09:57 AM

    so maybe at another level ?

    (your link does not work for me but I will take a look at the Empower site)


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 13.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 10:03 AM

    Not that I know, will have to wait for other members to comment on it


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 14.  RE: Hide empty or null fields

    Posted Wed April 13, 2016 10:09 AM

    this nothing urgent… not a problem… ok let’s wait :slight_smile:

    thanks for your help.

    Regards


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 15.  RE: Hide empty or null fields

    Posted Tue May 02, 2017 04:30 PM

    Hi Cedric,

    Did you get a solution ?

    even we are facing the same issue.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 16.  RE: Hide empty or null fields

    Posted Wed May 03, 2017 05:21 AM

    Hi,

    It has been a long time… I’ve forgotten the problem :wink:
    More serioulsy, I think i’ve corrected the problem using the solution recommended by Holger (in this post)
    Regards


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB