cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping

Former Member
0 Kudos

Hello,

I have implement a simple mapping between to IDOC-Types in JAVA. As first I would test the mapping therefore I read the InputStream from a testfile, but this did not work. Can anybody help me?

Source code:

SAXBuilder parser = new SAXBuilder();

Document src_doc = parser.build(new FileInputStream("CRMXIF_ORDER_SAVE_TEMPLATE.xml"));

The parser.build statement makes the error:

java.lang.NoClassDefFoundError: com/sap/guid/GUIDFormatException

at com.sap.aii.utilxi.log.impl.LoggerImpl.log(LoggerImpl.java:168)

at com.sap.aii.utilxi.log.api.Logger.log(Logger.java:138)

at com.sap.aii.utilxi.prop.api.PropertySourceFactory.getPropertySource(PropertySourceFactory.java:56)

at com.sap.aii.utilxi.misc.api.AIIProperties.sync(AIIProperties.java:519)

at com.sap.aii.utilxi.misc.api.AIIProperties.(AIIProperties.java:292)

at com.sap.aii.utilxi.misc.api.AIIProperties.getInstance(AIIProperties.java:319)

at com.sap.aii.utilxi.xml.api.XMLServices.getParserFactory(XMLServices.java:144)

at com.sap.aii.utilxi.xml.xdom.io.XDOMInputter.parse(XDOMInputter.java:203)

at com.sap.aii.utilxi.xml.xdom.io.XDOMInputter.read(XDOMInputter.java:166)

at com.sap.aii.utilxi.xml.jdom.SAXBuilder.build(SAXBuilder.java:60)

at XIMapping.Map2Orders.main(Map2Orders.java:54)

Exception in thread "main"

Thanks for help

Björn

Accepted Solutions (0)

Answers (1)

Answers (1)

Andrzej_Filusz
Contributor
0 Kudos

Hi!!!

Are you testing your java mapping after adding it to the Repository or outside it (from command line)?

If you are doing it outside then have you got aii_util_misc.jar(there is GUIDFormatException class) file in your CLASSPATH?

To test java mapping from command line you have to have aii_map_api.jar file in your CLASSPATH.

If you want to test your java mapping, I would recommend you to use code like this below (look at the main function) rather than your source code.

public class YOURMAPPING implements StreamTransformation {

private Map m_param;

public void setParameter(Map param) {

m_param = param;

}

public void execute(InputStream in, OutputStream out) {

// write your logic here

// for example parsing input stream

DefaultHandler handler = this;

SAXParserFactory factory = SAXParserFactory.newInstance();

try {

SAXParser saxParser = factory.newSAXParser();

this.out = out;

saxParser.parse(in, handler);

} catch (Throwable t) {

t.printStackTrace();

}

}

(...)

public static void main(String args[]) throws Exception {

System.out.println("Start");

YOURMAPPING mapping = new YOURMAPPING();

mapping.setParameter(new Hashtable());

mapping.execute(new FileInputStream("CRMXIF_ORDER_SAVE_TEMPLATE.xml"), new FileOutputStream("output.xml"));

System.out.println("Done.");

}

}

Regards,

Andrzej Filusz

Former Member
0 Kudos

Hi Andrzej,

I'm testing it outside in Eclipse with the XI3.0 libs. I have added the aii_util_misc.jar, aii_map_api.jar, aii_util.log.jar, aii_util_xml.jar, aii_utilxi_misc.jar, inqmyxml.jar.

Following causes an error:

DefaultHandler handler = this;

And which SAXParser do you use?

javax.xml.parsers.SAXParser or com.inqmy.lib.xml.parser.SAXParser

Regards

Björn

Andrzej_Filusz
Contributor
0 Kudos

I suppose I was using javax.xml.parsers.SAXParser. Here are my all imports:

import com.sap.aii.mapping.api.StreamTransformation;

import java.io.*;

import java.util.Map;

import javax.xml.parsers.*;

import org.xml.sax.*;

import org.xml.sax.helpers.*;

Andrzej Filusz

Andrzej_Filusz
Contributor
0 Kudos

Hi!

I'm sorry I've forgotten to add that your class should also extends DefaultHandler.

Regards,

Andrzej Filusz

Former Member
0 Kudos

No Problem.

I solved the problem by testing my mapping in the Repository and it works.

Many thanks

Björn

Former Member
0 Kudos

Hello,

How you could test a mapping in the repository?

Thanks,

Former Member
0 Kudos

Hello Enrique,

I can only tell you the way in XI 3.0. I don't know, if this is the same way in XI2.0.

At Interface-Mapping is a Tab-Page 'TEST' where you can upload a sample document

you are able to upload a sample document (load xml-instanz) and then you can execute the mapping with this file.

I hope this can help you.

Regards

Björn

Former Member
0 Kudos

Björn,

I don´t understand really good the concept of mapping test. When you test a mapping refers to test only the XML structures and corelations?, or with proxys you are able in the Integration repository to test this mapping connecting with the involved systems in the interface?.

In this case what is the best place to test an interface in XI, in BC you can test in every moment any step of the scenario and you have one tool to make all, but in XI i don´t see it clear.

Sorry, I im stucked now, probably because i am new with this.

Thanks a lot Björn, i will apreciate any comment or help.

Enrique.