Not able to convert ArrayList of List to array in java service webmethods

Below is my ArrayList:

ArrayList<ArrayList> Record = new ArrayList<ArrayList>();

I am using below code to get output:

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();

					// CalPattern
						IDataUtil.put( pipelineCursor_1, "Record", Record) ;
						IDataUtil.put( pipelineCursor_1, "message", message );
						
						idcout.destroy();
						pipelineCursor_1.destroy();

But getting output in Object form with required value in it. I want output in IS document list.

When I tried to convert ArrayList into Array as mentioned below , I have got an error:

// pipeline
IData[][] FinalRecord = Record.toArray(new IData[Record.size()][]);
IDataCursor pipelineCursor_1 = pipeline.getCursor();

					// CalPattern
						IDataUtil.put( pipelineCursor_1, "Record", FinalRecord) ;
						IDataUtil.put( pipelineCursor_1, "message", message );
						
						idcout.destroy();
						pipelineCursor_1.destroy();

Error:java.lang.ArrayStoreException: null

Please help!!

Can you explain your requirement and need for this java service?

Hi,

I have document list as an input . Document list contains 12 strings each representing calendar month. Each string contains binary digits representing 0 as non working days and 1 as working days.

Now I need to parse each string to get the output in a doc week wise. (E.g IS doc will contain 7 strings each represent week days…Monday =1, Tuesday=0…etc)

so thats why I have taken two array lists for output:

ArrayList CalPattern = new ArrayList();
ArrayList<ArrayList> Record = new ArrayList<ArrayList>();

:
:
:(some logic)
:

// create output object

		output = IDataFactory.create();
		idcout = output.getCursor();
		:
		:
		IDataUtil.put.....
		:
		:
		
		CalPattern.add(output);}

Record.add(CalPattern);

IDataCursor pipelineCursor_1 = pipeline.getCursor();
					
	// CalPattern
			IDataUtil.put( pipelineCursor_1, "Record", Record.toArray(new IData[Record.size()][])) ;
			IDataUtil.put( pipelineCursor_1, "message", message );
						
			idcout.destroy();
			pipelineCursor_1.destroy();

In the end I am converting Record array list of list into array but still getting output in object form.

Answers to this problem will be appreciated!!

Record is type of ArrayList<ArrayList>, so after convert it to array, this is an ArrayList array, still can’t be recognized by webMethods, unless you could convert it to IData.

Could you please tell me how to convert ArrayList array to IData???

Try this for conversion…

ArrayList docList=new ArrayList();
docList.add(IData1);

//conversion
docList.toArray(new IData[docList.size]);

ArrayList can’t be converted to IData, only ArrayList<ArrayList> can. I saw your Record variable is ArrayList<ArrayList> type.