How to get the xml file in the java service programmatically

Hi, I was told to write a cache logic using “Ehcache”. Here I have to get the ehcache.xml file to IS java service programmatically, and I have searched for that and I found something.

It was told that we can use

context.connect(server, username, password)

but it is for submitting the xml file to that server, here I want to retrieve the xml file to the IS programmatically.

Please suggest me an idea.

Thanks,
Venkat

If you want to do it from webMethods, you can use getFile service which will bring the XML data in bytes… Use xmlStringToNode, and NodeToDocument service to view the XML in IS document format…

Senthil

Hi Senthil, I see what you are saying but in webMethods 8.0 we have a enhanced “getFile” java service which gives the file data in either “byte”, “stream”, “reader” or “string”.

I am taking the output of that service as “string” and directly using it but it is giving me “null”, I am not getting where is the problem.

Please go through the documentation of 8.0 version before looking into this code for “getFile” built-in java service.

IData loadAs=IDataFactory.create();
IDataCursor loadAsCursor=loadAs.getCursor();
loadAsCursor.setValue(((Object) “string”));
try {
context.invoke(“pub.file”,“getFile”, loadAs);
body=context.invoke(“pub.file”,“getFile”,fileName);
} catch(Exception e) {
e.printStackTrace();
throw new ServiceException(“\n”+“Could not invoke the file”);
}
try {
bodyCursor=body.getCursor();
if(bodyCursor.first(“string”)) {
string=IDataUtil.getIData(bodyCursor,“string”);
stringCursor=string.getCursor();
xmlFileData=(String) stringCursor.getValue();
}
/if(pipeLineCursor.first(“body”)) {
body=IDataUtil.getIData(pipeLineCursor,“body”);
bodyCursor=body.getCursor();
if(bodyCursor.first(“string”)) {
string=IDataUtil.getIData(bodyCursor,“string”);
stringCursor=string.getCursor();
xmlFileData=(String) stringCursor.getValue();
}
}
/
/if(pipeLineCursor.first(“string”)) {
string=IDataUtil.getIData(bodyCursor,“string”);
stringCursor=string.getCursor();
xmlFileData=(String) stringCursor.getValue();
}
/
/if(pipeLineCursor.first(“body”) && bodyCursor.first(“string”)) {
xmlFileData=(String) stringCursor.getValue();
}
/
} catch(Exception e) {
e.printStackTrace();
throw new ServiceException(“\n”+“Could not retrieve data from the file”);
}

Thanks,
Venkat.