on 09-28-2005 6:54 AM
I have 2 mappings for interface transformation. The first is visual mapping and second - java mapping. There are 2 entry of interface mapping.
my java code is:
public void execute(InputStream in, OutputStream out) {
AbstractTrace trace = (AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE );
trace.addInfo("[EscapeMapping] Mapping is starting");
try {
int inputByte = 0;
while((inputByte = in.read()) != -1) {
out.write(inputByte);
}
} catch (Exception e) {
trace.addDebugMessage("[JAVA_MAPPING EXCEPTION] " + e.getMessage() + e.toString());
}
My my receiver gets an empty message.
message monitor:
<Trace level="1" type="T">Interface Mapping http://server.com/Mapping PersonToPersonJDBCInterfaceMapping</Trace>
<Trace level="1" type="T">*** APPLICATION TRACE TRUNCATED (for more details see LogViewer)***</Trace>
But I don't see my trace message in defaultTrace.trc
Coult you help me?
Why my mapping doesn't work? Do I need to restart J2EE Engine after new version of Java class mapping has been deployed?
I assume, that you need a line
out.flush();
in your code.
For testing your Java mapping standalone, you can add a main method in your class:
public static void main (String[] args) {
try {
InputStream in = new FileInputStream(new File("in.xml"));
OutputStream out = new FileOutputStream(new File("out.xml"));
MyClass change = new MyClass();
change.execute(in, out);
} catch (Exception e) {
e.printStackTrace();
}
}
The trace is written to the XML message trace, not to the defaultTrace.trc.
If you do not see it there, set the trace level to 3.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here a code sample for Java Mapping. It should deescape the XML.
package sample;
import com.sap.aii.mapping.api.*;
import java.io.*;
import java.util.Map;
public class Deescaping implements StreamTransformation{
public static void main (String[] args) {
try {
InputStream in = new FileInputStream(new File("in.xml"));
OutputStream out = new FileOutputStream(new File("out.xml"));
Deescaping change = new Deescaping();
change.execute(in, out);
} catch (Exception e) {
e.printStackTrace();
}
}
public void setParameter (Map map) {
}
public void execute (InputStream in, OutputStream out)
throws StreamTransformationException {
try {
int c;
while ((c = in.read()) != -1) {
if (c != '&') {
out.write(c);
} else {
// ampersand
String help = "&";
boolean exit = false;
// check the next 5 chars, if there is a ';'
for (int i = 0; i < 5 && !exit; i++) {
c = in.read();
if (c == -1) {
exit = true;
} else {
// another ampersand?
if (c == '&') {
out.write(help.getBytes());
help = "&";
i = 0; // check the next 5 chars
} else {
help = help + (char) c;
if (c == ';') {
exit = true;
}
if (help.equals("&")) {
help = "&";
}
if (help.equals("<")) {
help = "<";
}
if (help.equals(">")) {
help = ">";
}
if (help.equals(""")) {
help = """;
}
if (help.equals("'")) {
help = "'";
}
}
}
} // for
out.write(help.getBytes());
}
} // while
out.flush();
} catch (Exception e) {
throw new StreamTransformationException(e.getMessage(),e);
}
}
}
Regards
Stefan
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.