cancel
Showing results for 
Search instead for 
Did you mean: 

Access Imported Archive in User Defined Function

Former Member
0 Kudos

Hi!

I want to access a XML file in an user defined function in a message mapping. The XML file is included in an imported archive. I need the information out of this XML file for configuring an extended receiver determination.

Does anyone know how to solve this?

Best regards,

Daniel

Accepted Solutions (0)

Answers (1)

Answers (1)

moorthy
Active Contributor
0 Kudos

HI,

But you can use of Property file for that. -E.g-

/people/sap.user72/blog/2006/06/07/property-file-a-smart-use-in-xi-context

But I don't think so, you can access file from imported archive ..

So you can plan for Property file option for this.

Regards,

Moorthy

Former Member
0 Kudos

Hi Krishna,

a property file will be a solution but is has to be stored in the filesystem. In my scenario I prefer a file (not neccessary xml) which is editeable in the IR.

I tried something in this way (just for testing):

try {

DocumentBuilderFactory factory = null;

DocumentBuilder builder = null;

Document document = null;

Element element = null;

factory = DocumentBuilderFactory.newInstance();

builder = factory.newDocumentBuilder();

document = builder.parse(Container.class.getResourceAsStream("routing.xml"));

element = (Element)document.getElementsByTagName("BUSINESS_SYSTEM").item(0);

return element.getNodeValue();

} catch (Exception e) {

return "Crash: "+e.getMessage();

}

But it crashes, because the resource "routing.xml" cannot be found. I tried to add the namespace or the name of the imported archive or both as prefix, but it don't work. How can I find out under which address/url I can open the xml document?

Best regards,

Daniel

henrique_pinto
Active Contributor
0 Kudos

Daniel,

from what I've observed, you can access single files inside .jars using getResourceAsStream() method (pure getResource() won't work, don't know why), when doing java mappings. To check the full path of file, go for the imported .jar and check the path of that file.

If you have files with association to other files (for example, .xsds with import or include tags) the system won't be able to find the associations.

But for UDF's, I guess you had to have the file in the same class .jar. I don't if that's possible. I think you'll have to use filesystem solution...

Regards,

Henrique.

Former Member
0 Kudos

Hi Henrique,

thanks for the answer

A filesystem solution... I just try to get away from that, because it makes the installation of the content more complicated

I saw an XI solution which used this technique, but unfortunately I haven't took a deeper look how they solved it.

Best regards,

Daniel

Former Member
0 Kudos

Hi!

It seems that this version is working:

...

document = builder.parse(this.getClass().getClassLoader().getResourceAsStream("routing.xml"));

...

Best regards,

Daniel