Xml import in batch process ....???

Dear All,

While working on XML import using batch process requirement i came across an ERROR using the following sample code, the code works fine if it is not run as a batch process…Please help

Error:

Request for the permission of type ‘FileIOPermission’ failed.
(S)\Classes\FileIOPermission\demand
(S)\Classes\XmlDocument\newFile
(S)\Classes\ReadingXMLFile\run - line 4
(S)\Classes\BatchRun\runJobStatic - line 63

Code:

public void run()
{
XMLDocument XMLdoc = XMLDocument::newFile(@“D:\Items.xml”);
int i,CountItemtags;
K_Xml x; // table buffer
FileIOPermission fileIOPerm;

;
fileIOPerm = new FileIOPermission(@“D:\Items.xml”,“r”);

fileIOPerm.assert();

XMLdoc.loadXml(XMLdoc.toString());

countItemTags = xmldoc.getElementsByTagName(‘AccountNum’).length();

info (strfmt(‘Number of tags with name Item - %1’, countItemTags));

for (i = 0 ; i < countItemTags; i++)
{

x.AccountNum = xmldoc.getElementsByTagName(‘AccountNum’).item(i).text();

x.AccountName = xmldoc.getElementsByTagName(‘AccountName’).item(i).text();

x.insert();
}
}

Regards,

kaushik

Hi,

Code doesn’t work in Batch because the file is being created at client tier. Altering the file creation at server tier should fix the problem. For more info, please search here as this was discussed many times.

Hi Harish,

Thanks for the reply, i did not find any related post. Could you please suggest me any link…?

Regards,

kaushik

Hi Harish,

I am also working on the same Issue, was not able to do it.

Can any body provide the related Links with solutions.

Varma

Hi,

Looking at your code again perhaps this issue may be because of the way , can you try following -


public void run()
{

XmlDocument XMLDoc;
FileIOPermission readPermission;
#file

;

readPermission = new FileIOPermission(, #io_read);
readPermission.assert();

XMLDoc = XmlDocument::newFile();

CodeAccessPermission::revertAssert();

if (XMLDoc)
{

}

}


And regarding previous posts here, try searching for ‘FileIOPermission’. I did a quick search for you and found this - http://dynamicsuser.net/forums/p/27614/148286.aspx#148286