Get Datatype of a variable in webMethods

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?

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

1 Like

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

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

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.

2 Likes

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/

2 Likes

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.

1 Like

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

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.