在SAP PI 7.5中,无法在参数化的Java Mapping中显示树状视图。

【在SAP PI 7.5中,无法在参数化的Java Mapping中显示树状视图。】落花踏尽游何处,笑入胡姬酒肆中。这篇文章主要讲述在SAP PI 7.5中,无法在参数化的Java Mapping中显示树状视图。相关的知识,希望能为你提供帮助。
我的工作是 parameterized java映射。当在Operation Mapping中测试时,它给了我们 错误 Unable to display tree view; Error when parsing an XML document (Premature end of file.) 而跟踪日志显示 Resource not found: META-INF/services/javax.xml.transform.TransformerFactory . 我们面临同样的问题 DocumentFactory 但我们写了下面的代码,它解决了这一问题。documentfactory 发出

DocumentBuilderFactory factory = new com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl();

但我们仍然面临同样的错误 TransformerFactory. 请在下面找到整个代码,并请让我知道要做的修改。
XmlNFe_To_Mail。
package nfeb2b.company; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; //import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; //import javax.xml.parsers.*; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; //import org.w3c.dom.Node; import org.w3c.dom.Text; //import org.xml.sax.SAXException; //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; import com.sap.aii.mapping.lookup.Channel; import com.sap.aii.mapping.lookup.LookupService; import com.sap.aii.mapping.lookup.Payload; import com.sap.aii.mapping.lookup.RfcAccessor; import com.sap.aii.mapping.lookup.XmlPayload; publicclass XmlNFe_To_Mail extends AbstractTransformation { private String prefixoSubject = new String(); private String emailFrom = new String(); private String prefixoDocumento = new String(); private String frase = new String(); private String gap = ""; //private AbstractTrace trace = null; //private Map map = null; public String BSSystem; public String ComChannel; public String Emails; private final String NFE_EMPRESA = "NFE Company "; private final String NFe = "NFE"; private final String NFe_Mail = "nfe@company.com"; public String email=""; public String idNFe = ""; public String numeroNF = ""; public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {BSSystem= arg0.getInputParameters().getString("BS_NAME"); ComChannel=arg0.getInputParameters().getString("CHANNEL_NAME"); Emails=arg0.getInputParameters().getString("EMAIL"); getTrace().addInfo("Business System: " +BSSystem+ " Channel:" +ComChannel+" Emails:"+Emails); this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream()); } public void execute(InputStream in, OutputStream out) throws StreamTransformationException { // TODO Auto-generated method stub getTrace().addInfo("Before Try Block"); try { getTrace().addInfo("Inside Try Block"); configParamEmail(); getTrace().addInfo("After ConfigParamEmail"); BufferedReader inpxml = new BufferedReader(new InputStreamReader(in)); StringBuffer buffer = new StringBuffer(); String line = ""; String quebra = System.getProperty("line.separator"); while ((line = inpxml.readLine()) != null) { line.replaceAll("", ""); line.replaceAll(quebra, ""); line.replaceAll(" /> ", "/> "); line.replaceAll(" /> ", "/> "); line.replaceAll(" /> ", "/> "); buffer.append(line); } getTrace().addInfo("After WhileLoop"); String inptxml = buffer.toString(); inptxml = inptxml.replace("", ""); inptxml = inptxml.replaceAll(quebra, ""); inptxml = inptxml.replaceAll(" /> ", "/> "); inptxml = inptxml.replaceAll(" /> ", "/> "); inptxml = inptxml.replaceAll(" /> ", "/> "); idNFe = inptxml.substring(inptxml.indexOf("< chNFe> ") + 7, inptxml.indexOf("< /chNFe> ")); numeroNF = idNFe.substring(25, 34); getTrace().addInfo("idNFE value:"+idNFe); getTrace().addInfo("numeroNF value:"+numeroNF); String pdf = ""; getTrace().addInfo("Before LookUp"); getTrace().addInfo("Going to GetValue"); this.getValue(idNFe); // monta XML de saida XiMail getTrace().addInfo("Before DocumentBuilderFactory"); DocumentBuilderFactory factory = new com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl(); DocumentBuilder db = factory.newDocumentBuilder(); Document docout = db.newDocument(); Element root = docout.createElement("ns0:Mail"); root.setAttribute("xmlns:ns0", "http://sap.com/xi/XI/Mail/30"); //BufferedReader bfr = new BufferedReader(new InputStreamReader(in, "utf-8")); docout.appendChild(root); getTrace().addInfo("Root value: "+root); Element subject = docout.createElement("Subject"); root.appendChild(subject); Text subjectText = docout.createTextNode(getPrefixoSubject() + numeroNF); getTrace().addInfo("SubjectText: "+subjectText); // Cria// campo subject.appendChild(subjectText); // Cria elemento From Element from = docout.createElement("From"); root.appendChild(from); Text fromText = docout.createTextNode(getEmailFrom()); // Cria valor// campo from.appendChild(fromText); getTrace().addInfo("FromText: "+fromText); if (email.length() > 0) { email += "; "; } else { email = this.getEmaillist(); } getTrace().addInfo("Email: "+email); // Cria elemento ToElement to = docout.createElement("To"); root.appendChild(to); Text toText = docout.createTextNode(email); getTrace().addInfo("toText: "+toText); // Cria valor campo to.appendChild(toText); // Cria elemento Content Type Element contentType = docout.createElement("Content_Type"); root.appendChild(contentType); // Text contentTypeText = docout.createTextNode("application/xml"); // //Cria valor campo Text contentTypeText = docout.createTextNode("multipart/mixed; boundary=--AaZz"); // Cria // valor getTrace().addInfo("contentTypeText: "+contentTypeText); // campo contentType.appendChild(contentTypeText); // Criando o corpo de texto do e-mail e o anexo BodyText texto = new BodyText(idNFe, getFrase(), inptxml, pdf); // Cria elemento Content Element content = docout.createElement("Content"); root.appendChild(content); Text contentText = null; // substituir a sua empresa if ("NFE: ".equalsIgnoreCase(getPrefixoSubject())) { contentText = docout.createTextNode(texto.getnfeText()); } // substituir a sua empresa else if ("NFE CANCELADA : ".equalsIgnoreCase(getPrefixoSubject())) { contentText = docout.createTextNode(texto.getCnfeText()); } else if ("COE FMC: ".equalsIgnoreCase(getPrefixoSubject())) { contentText = docout.createTextNode(texto.getcceText()); } getTrace().addInfo("contentText: "+contentText); content.appendChild(contentText); /*Transformer trns = TransformerFactory.newInstance().newTransformer(); DOMSource targetMsg = new DOMSource(docout); StreamResult stRslt = new StreamResult(out); trns.transform(targetMsg, stRslt); */TransformerFactory tf=TransformerFactory.newInstance(); Transformer transform=tf.newTransformer(); transform.transform(new DOMSource(docout), new StreamResult(out)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // Exception Handling } } }public String getGap() { return gap; }public void setGap(String gap) { this.gap = gap; }public String getFrase() { return frase; }public void setFrase(String frase) { this.frase = frase; }public String getBSystem(){ return BSSystem; }public String getEmaillist(){ return Emails; }public String getCChannel() { return ComChannel; }public String getPrefixoSubject() { return prefixoSubject; }public void setPrefixoSubject(String prefixoSubject) { this.prefixoSubject = prefixoSubject; }public String getEmailFrom() { return emailFrom; }public void setEmailFrom(String emailFrom) { this.emailFrom = emailFrom; }public String getPrefixoDocumento() { return prefixoDocumento; }public void setPrefixoDocumento(String prefixoDocumento) { this.prefixoDocumento = prefixoDocumento; }public String getValue(String idNFe){ String contentnew; String rfcxml="< ?xml version="1.0" encoding="UTF-8"?> "+"< ns0:OTC_NFE_MAIL_OUTPUT xmlns:ns0="urn:sap-com:document:sap:rfc:functions"> "+"< I_ACCESS_KEY> " + idNFe + "< /I_ACCESS_KEY> < I_CANCEL/> < /ns0:OTC_NFE_MAIL_OUTPUT> "; getTrace().addInfo("RFCXML:"+rfcxml); RfcAccessor accessor = null; ByteArrayOutputStream outRFC = null; try{ getTrace().addInfo("Went inside GetValue"); Channel channel= LookupService.getChannel(getBSystem(),getCChannel()); accessor= LookupService.getRfcAccessor(channel); getTrace().addInfo("After LookUp"); InputStream inputStream = new ByteArrayInputStream(rfcxml.getBytes()); XmlPayload payload= LookupService.getXmlPayload(inputStream); Payload rfcOutPayload= accessor.call(payload); InputStream inputs = rfcOutPayload.getContent(); outRFC = new ByteArrayOutputStream(1024); byte[] bufferbyte = new byte[1024]; for (int read = inputs.read(bufferbyte); read > 0; read = inputs.read(bufferbyte)) { outRFC.write(bufferbyte, 0, read); } contentnew = outRFC.toString(); getTrace().addInfo("Content"+contentnew); int Start_Index , End_Index ; Start_Index = outRFC.toString().indexOf("< E_EMAIL> ") + 9; getTrace().addInfo("StartIndex"+Start_Index); End_Index= outRFC.toString().indexOf("< /E_EMAIL> "); getTrace().addInfo("EndIndex"+End_Index); email = outRFC.toString().substring(Start_Index,End_Index); getTrace().addInfo("Email"+email); return email; } catch(Exception e){throw new RuntimeException("Error message"+e); }}private void configParamEmail() { setEmailFrom(NFe_Mail); setPrefixoDocumento(NFe); setPrefixoSubject(NFE_EMPRESA); }/*public void setParameter(Map arg0) { // TODO Auto-generated method stub}*/}

BodyText.java.XmlNFe_To_Mail
package nfeb2b.company; 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 BodyText extends AbstractTransformation{public String nfeText = new String(); public String cnfeText = new String(); public String cceText = new String(); public String content = new String(); public String chaveNFe = new String(); public String frase = new String(); public String xmlString = new String(); public final String gap = ""; public String numeroNFe = new String(); public String dataNFe = new String(); public String serieNFe = new String(); public String pdf = new String(); public String pdfattachment_nfe= "NF-e- "; public String pdfattachment_cnfe="NF-e Cancelada - "; public String pdfattachment_ccfe="CC-e - "; // public String sefazNFe = new String(); public BodyText() {}public BodyText(String chaveNFe, String frase, String xmlString, String pdf) { this.chaveNFe = chaveNFe; this.frase = frase; this.xmlString = xmlString; this.pdf = pdf; this.numeroNFe = chaveNFe.substring(25, 34); this.dataNFe = chaveNFe.substring(4, 6) + "/20" + chaveNFe.substring(2, 4); this.serieNFe = chaveNFe.substring(22, 25); // this.sefazNFe = chaveNFe.substring(0,2); pdfattachment_nfe = pdfattachment_nfe + chaveNFe + ".xml"; pdfattachment_cnfe=pdfattachment_cnfe + chaveNFe + ".xml"; pdfattachment_ccfe=pdfattachment_ccfe + chaveNFe + ".xml"; }public String getGap() { return gap; }public String getnfeText() {nfeText = "Prezado cliente, " + getGap() + "Segue" + getGap() + getGap() + "Número da NF-e: " + numeroNFe + getGap() + "Serie: " + serieNFe + getGap() + "Data emiss?o (MM/AAAA): " + dataNFe + getGap() + getGap() + "Atenciosamente," + getGap() + getGap() + "FMC"; content = "----AaZz"+ "Content-Type: text/html; charset=UTF-8" +"" + "Content-Disposition: inline" + nfeText + "----AaZz" + "Content-Type: application/pdf; name=" + pdfattachment_nfe + ""+ "Content-Disposition: attachment; filename=" +pdfattachment_nfe + ""+ "" +""; return content; }public String getCnfeText() {cnfeText = "Prezado cliente, " + getGap() + "Segue." + getGap() + getGap() + "Número da NF-e: " + numeroNFe + getGap() + "Série: " + serieNFe + getGap() + "Data emiss?o (MM/AAAA): " + dataNFe + getGap() + getGap() + "Atenciosamente," + getGap() + getGap() + "FMC"; content = "----AaZz"+ "Content-Type: text/html; charset=UTF-8" +"" + "Content-Disposition: inline" + nfeText + "----AaZz" + "Content-Type: application/pdf; name=" + pdfattachment_nfe + ""+ "Content-Disposition: attachment; filename=" +pdfattachment_nfe + "" + "Content-Transfer-Encoding: base64" + "" +""; return content; }public String getcceText() { cceText = "Prezado cliente, " + getGap() + "Segue ." + getGap() + getGap() + "Número da NF-e que recebeu corre??o eletr?nica: " + numeroNFe + getGap() + "Série: " + serieNFe + getGap() + "Data emiss?o (MM/AAAA): " + dataNFe + getGap() + getGap() + "Atenciosamente," + getGap() + getGap() + "FMC"; content = "----AaZz"+ "Content-Type: text/html; charset=UTF-8" +"" + "Content-Disposition: inline" + nfeText + "----AaZz" + "Content-Type: application/pdf; name=" + pdfattachment_nfe + ""+ "Content-Disposition: attachment; filename=" +pdfattachment_nfe + "" + "Content-Transfer-Encoding: base64" + "" +""; return content; }@Override public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException { // TODO Auto-generated method stub}}

请看下面的跟踪 日志。
Resource not found: META-INF/services/javax.xml.transform.TransformerFactorycom.sap.aii.ib.server.mapping.execution.MappingClassNotFoundException: META-INF/services/javax.xml.transform.transformerfactory at com.sap.aii.ib.server.mapping.execution.InternalMappingFinder.getInputStream(InternalMappingFinder.java:125) at com.sap.aii.ib.server.mapping.execution.InternalMappingFinder.readFile(InternalMappingFinder.java:63) at com.sap.aii.ib.server.mapping.execution.MappingLoader.findResources(MappingLoader.java:354) at java.lang.ClassLoader.getResources(ClassLoader.java:1241) at java.lang.ClassLoader.getResources(ClassLoader.java:1237) at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:348) at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393) at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474) at javax.xml.transform.FactoryFinder$1.run(FactoryFinder.java:279) at java.security.AccessController.doPrivileged(Native Method) at javax.xml.transform.FactoryFinder.findServiceProvider(FactoryFinder.java:275) at javax.xml.transform.FactoryFinder.find(FactoryFinder.java:251) at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:106) at nfeb2b.fmc.XmlNFe_To_Mail.execute(XmlNFe_To_Mail.java:195) at nfeb2b.fmc.XmlNFe_To_Mail.transform(XmlNFe_To_Mail.java:69) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:112) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep(SequenceMapping.java:40) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:87) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:54) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:139) at com.sap.aii.ibrep.server.mapping.exec.ExecuteIfMapCommand.execute(ExecuteIfMapCommand.java:33) at com.sap.aii.ib.server.mapping.exec.CommandManager.execute(CommandManager.java:43) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:40)

请告诉我需要做哪些修改。谢谢 :)
答案检查说明 2669221 - Java 映射。未找到资源。META-INFservicesjavax.xml.parsers.DocumentBuilderFactory。
通过备注2669221应用这两行字。
javax.xml.parsers.DocumentBuilderFactory = com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl javax.xml.transform.TransformerFactory = com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

或者在调用工厂之前加上这两行字。
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");


    推荐阅读