Mapping single element list to list

I am trying to map a stringList1 to another stringList2 and then trying to check the size of the string list after that.
Unfortunately when, there is only one value in the input stringList1, then the mapped stringList2 is also converting to a string
Hence when i check the size of this stringList2 or invoke Makestrings service it is throwing the error as below

=============================================
class java.lang.String cannot be cast to class [Ljava.lang.String; (java.lang.String and [Ljava.lang.String; are in module java.base of loader ‘bootstrap’)
java.lang.ClassCastException
java.lang.ClassCastException: class java.lang.String cannot be cast to class [Ljava.lang.String; (java.lang.String and [Ljava.lang.String; are in module java.base of loader ‘bootstrap’)
at pub.list.appendToStringList(list.java:471)
at jdk.internal.reflect.GeneratedMethodAccessor176.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:404)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:759)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:39)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:53)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:339)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:33)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:401)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:629)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:434)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:392)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:260)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:231)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:263)
at com.wm.lang.flow.FlowMapInvoke.invokeService(FlowMapInvoke.java:189)
at com.wm.lang.flow.FlowMap.invoke(FlowMap.java:301)
at com.wm.lang.flow.FlowMap.invoke(FlowMap.java:166)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:662)
at com.wm.lang.flow.FlowState.stepIncremental(FlowState.java:576)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:464)
at wm.server.flowdebugger.singleStepMap(flowdebugger.java:1292)
at wm.server.flowdebugger.execute(flowdebugger.java:508)
at jdk.internal.reflect.GeneratedMethodAccessor455.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:414)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:759)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:39)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:53)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:339)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:33)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:401)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:629)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:434)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:392)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:260)
at com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java:119)
at com.wm.app.b2b.server.HTTPMessageHandler.process(HTTPMessageHandler.java:160)
at com.wm.app.b2b.server.HTTPDispatch.handleRequest(HTTPDispatch.java:203)
at com.wm.app.b2b.server.Dispatch.run(Dispatch.java:391)
at com.wm.util.pool.PooledThread.run(PooledThread.java:127)
at java.base/java.lang.Thread.run(Thread.java:829)

But works fine when multiple strings in stringList1

can someone please help how i can make sure that the string list doesnt convert to string even when the input is a string

Can you provide an example? Ideally with pseudo-code or detailed screenshots

@ jahntech.cj


and when debugging, observed that the partnerSystemId is coming as a string
image
and with the above mapping, the stringlist is also converting to string
image

Thanks. But I am a bit confused now. The screenshot shows only a single string to me. How is a string list coming into the picture?

As there is only one value in PartnerSystemId(stringList) it is taking up as a string by IS.
run time value is coming as below
image
and after mapping the run time value of distributionList/PartnerSystemId is also converting to a string
image

which is then throwing the error when performing list operations.

Where is “partnerSystemId” defined as a string list? All I can see are strings, indicated by the string icon.

Only because the field has a name that implies a list, does not mean that is technically a list. Lists have a different icon, so perhaps there is a misunderstanding here.

I am totally aware of defining string or a string list and here both the input an output are defined as string lists as you can see in the below pipeline


but during run time as there is only one value in the input stringList, IS is considering it as a string.

The strings you are seeing are from the debug log variables

Thanks, I hadn’t magnified the screenshot and therefore seen the icon as a single string.

The real question here is how the source string list gets created as a single string. If there is REALLY no way to fix this issue upstream, where the root cause lies, you can also employ a Java service to “convert” the string to a string list with one element.

1 Like

When you map a single element to an array, Integration Server usually adds it to the list without any problems but this is not the correct way to map a single element to an array. Correct way of mapping a single element to an array is after mapping the item, click the map and then from the pipeline panel, click the button next to delete (X) icon.

From the popped up window, add the index number, it is usually 0 but you can populate any array one by one so any number is ok.
Screenshot 2024-04-25 at 7.49.09 AM

Sometimes it doesn’t look like it is editable but it is as long as flow is locked and the field is an array, just click and add the number. You can do the same for the input. When you map an item like this, you can map multiple elements to a single array (with different indexes).

It will have a different color when you save it.

From the screenshot, I realized a little later that you are mapping from a string list to a string list. But you aren’t looping them?? Even if it is a single element you need to loop them or index them if they are coming from a list. You can only map a list to another list, not an element of a list to an element of a list without looping or indexing them! And if you map list to list, the output list will have the same element name as the input! It won’t magically convert the element names to the mapped lists element name!

The mapping isnt a problem at all. The issue is that source is not a StringList with one value in it, as it should be. Its actually a string. So the target will also be a string. Make sure the source is created correctly. If you dont have control over it then you can add a map step before the one you have. In that take the partnerSystemId field and map it to a field called partnerSystemIdList. Then use the new one and maps it to your target, That way it will work for both scenarios.

1 Like

It is not very clear in small thumbnail, but the source and the target are both coming from a string list. OP is trying to map from string list to string list directly without using a loop. If it were a single element string, not a list, IS would add that to the list.

Yes the map is correct. Both source and target are string lists. But in reality the source value is a string in the pipeline. If you have a map at runtime the type check doesnt happen. It just copies it as it is. Since the source is actually a string, it get copied to the target at a string too.

1 Like

Mapping is not correct. You need to loop it first, then map it. It would be a single element on both sides if it were correct. Check the document below.

https://documentation.softwareag.com/webmethods/designer/sdf10-15/webhelp/sdf-webhelp/#page/sdf-webhelp%2Fesb.flow.loop.inputArray.html

Or you can try the other method I mentioned earlier, but if you do it right, it will accept arrays as well, in case you need it in the future.

How is partnerSystemId being passed to wM IS? Is a query parameter via HTTP? Or something else? The MAP step itself looks okay so it seems this is potentially due to either the caller or if via HTTP due to a setting.

For HTTP calls, you can control how IS represents a query variable in the pipeline. The watt.server.http.listRequestVars setting controls how query vars are placed into the pipeline.

Of course, I’m just speculating about what may be the underlying cause. Please share how partnerSystemId is being passed and we’ll be able to provide better guidance.

3 Likes

the value is passed to wm IS in a soap call… in an xml doc… is there any server setting i can modify to control this

Just do the loop once and see if it helps. You are going towards wrong direction.

Can you share the steps that convert the XML string to an IS document? XML syntax is such that one cannot determine if a single element is supposed to be in a list without additional information from elsewhere. Either need to use a document type or set makeArrays/arrays so that xmlNodeToDocument knows which elements should be treated as a list even when only 1 element is present.

@reamon The mapping is wrong. You are sending him towards the wrong direction. Enlarge the picture here. You cannot map a list to a list without looping them first. Without the loop it will copy the list object, not the elements; hence it will have the old element names and won’t be found in pipeline.

@tahaseenshaik999 You can save the pipeline and see what you have there. Even if you have a single element, you need to either loop it, or map it using indexes.

Yes you can. Copy by reference is fine.There is no issue with mapping a list to a list, as long as you understand the 2 vars reference the same underlying list.

The description of the symptom indicates that the XML was not parsed with a document type or the proper arrays/makeArrays inputs – thus the single string element is a string var in the pipeline, not a list. Then it is mapped (by value) to the target doc – but as a string, not a string list because that’s what the source var type is. Then when the target doc element is passed to the service that expects an array, it fails because it is not an array.

This is classic behavior that everyone new to IS and XML runs into. Readily addressed by using a doc type and setting the right inputs to xmlNodeToDocument.

[Edit] @engin_arlak I know you’re not new. And @tahaseenshaik999 may not be new either but the profile was created in 2022 so might be. In any case, the comment is a generalization about this symptom, not about any specific participant here. :slight_smile:

If my speculation is correct, looping won’t solve the issue either – there will be no list over which to loop because the source var will be a string at runtime.

Of course, my assessment may be shown to be wrong once the OP shares the steps for the XML being converted to a doc.

I will back @reamon on this. Please see this example. I have mapped a string list to a string list inside a doc on output side. Exactly as the original poster. You will see that output appears correct. So I will again state that the mapping is correct.

The input

2024-04-30 10 27 37 (2)

The output

2024-04-30 10 27 37 (3)

Now on the other hand if you drop the inList variable and add a inList string variable. You will see a string in the output. you can see that below. Hope this clarifies the situation


es.

@tahaseenshaik999, please sahre how you are getting your input document constructed and we can suggest a way to force it to be a list.

1 Like