webMethods

 View Only
  • 1.  Get Datatype of a variable in webMethods

    Posted Fri February 02, 2024 08:20 AM

    Product/components used and version/fix level:

    Java Service in webMethods 10.15

    Detailed explanation of the problem:

    Hi, I am trying to check datatype of a variable using Java Service. I try to get datatype of a string which in doclist of doc. but I am getting class “com.wm.data.ISMemDataImpl” in output.

    my code

    public static final void new_javaService(IData pipeline) throws ServiceException {
    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();

    		// doc
    IData	doc = IDataUtil.getIData( pipelineCursor, "doc" );
    if ( doc != null)
    {
    IDataCursor docCursor = doc.getCursor();
    
    // i.docList
    IData[]	docList = IDataUtil.getIDataArray( docCursor, "docList" );
    if ( docList != null)
    {
    for ( int i = 0; i < docList.length; i++ )
    {
    Class<?> name = docList[i].getClass();
    
    IDataUtil.put(pipelineCursor, "name", String.valueOf(name));
    }
    
    }
    docCursor.destroy();
    }
    pipelineCursor.destroy();
    
    // pipeline
    
    }
    
    // --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
    
    
    
    // --- <<IS-END-SHARED-SOURCE-AREA>> ---
    

    image

    I need datatype of “name” in above image. please help! thanks in advance

    Error messages / full error message screenshot / log file:

    Getting “class com.wm.data.ISMemDataImpl” instead datatype name.

    Question related to a free trial, or to a production (customer) instance?


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


  • 2.  RE: Get Datatype of a variable in webMethods

    Posted Fri February 02, 2024 08:41 AM

    Hi Sireesha,

    what exactly would be the use case for such a service?

    Regarding your code:
    You are referring to the current docList-Element, which is a container type and not its child element “name”.
    You will have to retrieve the child element prior to checking its type.

    Regards,
    Holger


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


  • 3.  RE: Get Datatype of a variable in webMethods

    Posted Fri February 02, 2024 09:34 AM

    Hi Holger,

    I have to replace the value of a variable in Doc List if it’s type is String. So I am trying to get datatype.

    if variable datatype is String and value is “NULL”, I have to replace “NULL” value with “A”.

    Thanks
    Sireesha


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


  • 4.  RE: Get Datatype of a variable in webMethods

    Posted Fri February 02, 2024 11:05 AM

    Hi Sireesha,

    please provide a more detailed outline of your document/docList-structure together with some sample data.

    Eventually we will find a solution by using IS Built-In-Services for your requirement then.

    Regards,
    Holger


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


  • 5.  RE: Get Datatype of a variable in webMethods

    Posted Fri February 02, 2024 11:39 AM

    You know everything in Integration Server pipeline is usually a string right? When you implement a java service your pipeline is linked and passed to your Java service. That doesn’t necessarily mean that what you had in your pipeline and what you get in your java service as object, are entirely same.

    You should explain what your requirement is, not ask for a solution to your attempt. Currently you are asking questions about your attempted solution. Its called XY problem.
    https://xyproblem.info/


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


  • 6.  RE: Get Datatype of a variable in webMethods

    Posted Mon February 05, 2024 02:53 AM

    Based upon this description, this is simply trying to set a default value for a field if a value is not present, correct?

    Or are you looking for a literal string “NULL”? (Seems unlikely). But if you are checking for a literal “NULL” string, then this is easily doable in FLOW.

    You may be aware, but null entities do not have a data type. One cannot inspect a var that is null to see what type it is – it is nothing.

    If you’re simply trying to set a default value of ‘A’ this can be done in FLOW. No need for Java and certainly no need to check the data type.

    All that said, this almost feels like this is an interview question or perhaps a university assignment – it’s okay if it is, but that information will help the community steer you in the right direction.


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


  • 7.  RE: Get Datatype of a variable in webMethods

    Posted Mon February 05, 2024 05:41 AM

    Hi,

    in MAP step, when you map a variable from input to output, you can additionally set a default value on the output and mark “Overwrite pipeline value” as false.

    When input has a content, this one will be mapped and used further on, but if there is no value on the input, the value set on the output will be used instead.
    See “Working with Designer” and ServiceDevelopment Guides for further informations.

    Regards,
    Holger


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


  • 8.  RE: Get Datatype of a variable in webMethods

    Posted Fri February 02, 2024 11:34 AM

    Without more context my reply would be: The data type of a string is by definition string. :slight_smile:

    Of course you know that. So I want to join @Holger_von_Thomsen in asking for more details.


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