hi all,
I've a source structure like this below in PI.
<MAT>
<doc type>pdf</doc type
<subnumber>1234</subnumber>
<id>45ABC<id>
<matno>ABCD</matno>
<filename>transaction1.pdf</filename>
</MAT>
target structure would be the same but one more field <filecontent> which is bytearray content such as content=[101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10]
<MAT>
<doc type>pdf</doc type
<subnumber>1234</subnumber>
<id>45ABC<id>
<matno>ABCD</matno>
<filename>transaction1.pdf</filename>
<filecontent>bytearraycontent</filecontent
</MAT>
And target is HTTP post for posting the above attribute names and values in the body of HTML
I am writing a java mapping program because I have to read the <filename> tag value from the incoming xml and read the file from PI server location and convert the file content to bytearray and also to map it to target structure for HTTP post. I am requesting help from java experts here in modifying the program according to this requirement. pls help
package com.usahealth.mapping;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class ReadAttrMap extends AbstractTransformation {
@Override
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException {
AbstractTrace trace = null;
try {
// Initialize Trace
trace = getTrace();
// Get Input Message as DOM
DocumentBuilderFactory docBFactory = DocumentBuilderFactory
.newInstance();
docBFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBFactory.newDocumentBuilder();
Document inDoc = docBuilder.parse(in.getInputPayload()
.getInputStream());
inDoc.getDocumentElement().normalize();
// Read from PayLoad - here is where I need help to read the filename - convert it to byte array and read other xml tag values and pass to target structure for HTTP post. I am using HTTP receiver adapter for posting
} catch (Exception e) {
trace.addInfo(e.getMessage());
throw new StreamTransformationException("Mapping Exception: "
+ e.getMessage(), e);
}
}
}
thx
mike