Hi All
I am a newbie in webmethod.
In one of my java service i need to convert an arraylist into an IData Document.
Could someone help with the conversion,as i am getting typecasting error while executing below code:
IData[] doc = (IData[])sList.toArray();//sList is the arraylist.
Thanks in advance for the help.
Hello Pranav
Thats fine....but could you please tell me where am i getting wrong in the below cod:
IDataCursor pipelineCursor = pipeline.getCursor();
ArrayList sList = new ArrayList();
IDataUtil.put( pipelineCursor_1, "Doc", doc );
pipelineCursor_1.destroy();
---------------------------------------------------------
i want to convert the arrayList(sList) to an array before putting it in the output Documnet doc.
No need to define your code/logic, just follow the below instructions:
1) Create a empty service with your required Inputs and outputs.
2) Go to Tools and click on Generate code option.
3) Select for implementing this service option and then click on next.
4) Select in Specification both input and output, Select in which fields all fields option
5) Click on finish
6) You will receive a pop-up message "The generated code has been copied to the clipboard"
7) Click on ok and right click on your java service body and paste it.
I have defined the input as a document list variable as "docList" and inside docList i got two variables var1 and var2, then i have given output a document as "doc" and inside i got two variable var 1 and var2
[url=http://www.idnxchange.com/webmethods-interview-questions/3-webmethods-Interview-questions/127-how-to-convert-document-list-to-document-if-document-list-contain-documents-and-documents-contain-strings-field-how-to-convert-.html]Document list to Document[/url]
Shuvaday
Hi All
I am a newbie in webmethod.
In one of my java service i need to convert an arraylist into an IData Document.
Could someone help with the conversion,as i am getting typecasting error while executing below code:
IData[] doc = (IData[])sList.toArray();//sList is the arraylist.
Thanks in advance for the help.
Pavan
check the below code in order to read from a webMethods document list into wM Java service through IData object:
IData[] doclist = IDataUtil.getIDataArray(pipelineCursor, "doclist" );
This will read wM doc list content into your IData object.
if ( doclist != null)
{
for ( int i =0; i < doclist.length; i++ )
{
your logic.........
At last IDataUtil.put(pipelineCursor,"outlist",outList);
..
pipelineCursor.destroy();
Shuvaday
Hello Pranav sList = new ArrayList();
IDataCursor sCursor = Student[i].getCursor();
Thats fine....but could you please tell me where am i getting wrong in the below cod:
IDataCursor pipelineCursor = pipeline.getCursor();
ArrayList
IData Student[] = null ;
if ( Student != null)
{
for(int i =0;i
IData sDetails = IDataFactory.create();
IDataCursor fdc = sDetails.getCursor();
IDataUtil.put(fdc,"name",IDataUtil.getString(sCursor,"name"));
IDataUtil.put(fdc,"class",IDataUtil.getString(sCursor,"class"));
sList.add(sDetails);
sCursor.destroy();
}
}
pipelineCursor.destroy();
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
// Doc
IData [] doc = IDataUtil.getIDataArray(pipelineCursor_1,sList);
IDataUtil.put( pipelineCursor_1, "Doc", doc );
pipelineCursor_1.destroy();
---------------------------------------------------------
i want to convert the arrayList(sList) to an array before putting it in the output Documnet doc.
Pavan
Hi,
No need to define your code/logic, just follow the below instructions:
1) Create a empty service with your required Inputs and outputs.
2) Go to Tools and click on Generate code option.
3) Select for implementing this service option and then click on next.
4) Select in Specification both input and output, Select in which fields all fields option
5) Click on finish
6) You will receive a pop-up message "The generated code has been copied to the clipboard"
7) Click on ok and right click on your java service body and paste it.
I have defined the input as a document list variable as "docList" and inside docList i got two variables var1 and var2, then i have given output a document as "doc" and inside i got two variable var 1 and var2
When i ran the above steps i got the below code :
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
// docList
IData[] docList = IDataUtil.getIDataArray( pipelineCursor, "docList" );
if ( docList != null)
{
for ( int i = 0; i < docList.length; i++ )
{
IDataCursor docListCursor = docList[i].getCursor();
String var1 = IDataUtil.getString( docListCursor, "var1" );
String var2 = IDataUtil.getString( docListCursor, "var2" );
[b] // Here you can define your logic[/b]
docListCursor.destroy();
}
}
pipelineCursor.destroy();
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
// doc
IData doc = IDataFactory.create();
IDataCursor docCursor = doc.getCursor();
IDataUtil.put( docCursor, "var1", "var1" );
IDataUtil.put( docCursor, "var2", "var2" );
docCursor.destroy();
IDataUtil.put( pipelineCursor_1, "doc", doc );
pipelineCursor_1.destroy();
But I am not sure how you will be making an docList or array list with multiple documents to a single document :(
Raj Kumar
Check the below link:
[url=http://www.idnxchange.com/webmethods-interview-questions/3-webmethods-Interview-questions/127-how-to-convert-document-list-to-document-if-document-list-contain-documents-and-documents-contain-strings-field-how-to-convert-.html]Document list to Document[/url]
Shuvaday
Thanks a lot for your replies...
it helped :)