on 09-17-2008 5:01 PM
Hi All:
I'm writing an test adapter module that will read the payload and simply add one extra element in that with dummy value. I developed and configured it also. but when I execute the interface I am getting a message in moni with Error org.apache.crimson.tree.XmlDocument@18a992f.
Below is the AM code. Did I missed something? I will appreciate if you can point out the missed part.
I am using this Module at Sender side of File Adapter (SAP PI with SP-9)
package sample;
import java.io.InputStream;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.mp.module.ModuleException;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.XMLPayload;
import com.sap.aii.af.service.auditlog.Audit;
import com.sap.aii.af.service.auditlog.AuditDirection;
import com.sap.aii.af.service.auditlog.AuditLogStatus;
import com.sap.aii.af.service.auditlog.AuditMessageKey;
/**
* @ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>
* @ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>
* @ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>
* @ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>
* @stateless
*/
public class CreateElement implements SessionBean, Module {
private SessionContext myContext;
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext context) {
myContext = context;
}
public void ejbCreate() throws CreateException {
}
public ModuleData process(
ModuleContext moduleContext,
ModuleData inputModuleData)
throws ModuleException {
AuditMessageKey key=null;
Message msg = (Message)inputModuleData.getPrincipalData();
key = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
Audit.addAuditLogEntry(key,AuditLogStatus.SUCCESS,"Modules Called Done without Error");
XMLPayload payload = msg.getDocument();
InputStream inputStream = payload.getInputStream();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(inputStream);
//Get the element Message...
NodeList messageNL = doc.getElementsByTagName("Message");
//get the root element....
Node root = doc.getFirstChild();
Element ne = doc.createElement("NewElement");
Text text = doc.createTextNode("DOM");
Node nElement = ne.appendChild(text);
ne.appendChild(nElement);
root.appendChild(ne);
//Commit the payload...
byte b[] = doc.toString().getBytes();
payload.setContent(b);
key = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
Audit.addAuditLogEntry(key,AuditLogStatus.SUCCESS,"Modules Called Done without Error");
}
catch (Exception e){
Audit.addAuditLogEntry(key,AuditLogStatus.ERROR,"Module Call fails due to Error");
ModuleException exception = new ModuleException();
throw exception;
}
return inputModuleData;
}
}
Thanks
Farooq
Edited by: Farooq Farooqui on Sep 17, 2008 9:33 PM
Farooq,
This line is causing ur issue........
Text text = doc.createTextNode("DOM");
Comment that and you should be ok.........If you want to leave that line, Then you need to find and add Crimson.jar to your java build path............
Regards
Ravi Raman
P.S:-- Dont forget the points if it fixes the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.