Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 调用方法getInputParameters()时发生NullPointerException_Java_Nullpointerexception_Sap_Sap Xi_Sap Pi - Fatal编程技术网

Java 调用方法getInputParameters()时发生NullPointerException

Java 调用方法getInputParameters()时发生NullPointerException,java,nullpointerexception,sap,sap-xi,sap-pi,Java,Nullpointerexception,Sap,Sap Xi,Sap Pi,我正在SAP PI 7.5中使用以下参数进行参数化Java映射,这些参数由操作映射中指定的标记名绑定 (BS_NAME,CHANNEL_NAME,EMAIL). 在使用有效负载测试OM的测试选项卡中的以下java映射时,会出现以下错误: 尝试调用从局部变量“this**”加载的对象的字段加载的null对象的com.sap.aii.mapping.api.TransformationInput.getInputParameters()方法时发生NullPointerException 我调试了

我正在SAP PI 7.5中使用以下参数进行参数化Java映射,这些参数由操作映射中指定的标记名绑定

(BS_NAME,CHANNEL_NAME,EMAIL). 
在使用有效负载测试OM的测试选项卡中的以下java映射时,会出现以下错误:

尝试调用从局部变量“this**”加载的对象的字段加载的null对象的com.sap.aii.mapping.api.TransformationInput.getInputParameters()方法时发生NullPointerException

我调试了代码,但没有发现问题,有什么建议吗

请查找以下XmlNFe_To_邮件类的Java代码。BodyText类还用于获取某些内容。XmlNFe_To_邮件类中遇到错误

public class 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 = "\n\r";
private AbstractTrace trace = null;
private Map map = null;
private String BSSystem = "";
private String ComChannel = "";
private String Emails = "";
private final String NFE_EMPRESA = "NFE Company: ";
private final String NFe = "NFE";
private final String NFe_Mail = "nfe@company.com";
TransformationInput input = null;
TransformationOutput output = null;
public void execute(InputStream in , OutputStream out) throws StreamTransformationException {
    // TODO Auto-generated method stub
    {
        BSSystem = input.getInputParameters().getString("BS_NAME");
        ComChannel = input.getInputParameters().getString("CHANNEL_NAME");
        Emails = input.getInputParameters().getString("EMAIL");
        try {
            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("\r\n", "");
                line.replaceAll(quebra, "");
                line.replaceAll(" />", "/>");
                line.replaceAll(" />", "/>");
                line.replaceAll(" />", "/>");
                buffer.append(line);
            }
            String inptxml = buffer.toString();
            inptxml = inptxml.replace("\r\n", "");
            inptxml = inptxml.replaceAll(quebra, "");
            inptxml = inptxml.replaceAll(" />", "/>");
            inptxml = inptxml.replaceAll(" />", "/>");
            inptxml = inptxml.replaceAll(" />", "/>");
            String idNFe = "";
            String numeroNF = "";
            String idEvent = "";
            idNFe = inptxml.substring(inptxml.indexOf("<chNFe>") + 7, inptxml.indexOf("</chNFe>"));
            numeroNF = idNFe.substring(25, 34);
            if (inptxml.indexOf("infEvento") > 0) {
                idEvent = inptxml.substring(inptxml.indexOf("<tpEvento>") + 10, inptxml.indexOf("</tpEvento>"));
                if (idEvent.length() > 0) {
                    if (idEvent.equals("111111")) {
                        this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll("NFE", "CancNFe"));
                        this.setPrefixoSubject(this.getPrefixoSubject().replaceAll("NFE", "NFE CANCELADA"));
                    } else if (idEvent.equals("100000")) {
                        this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll("NFE", "CCE"));
                        this.setPrefixoSubject(this.getPrefixoSubject().replaceAll("NFE", "CCE"));
                    } else {
                        this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll("NFE", "ManDest"));
                        this.setPrefixoSubject(this.getPrefixoSubject().replaceAll("NFE", "MANIFESTO"));
                    }
                }
            }
            Channel chn = null;
            RfcAccessor rfc = null;
            String email = "";
            String pdf = "";
            chn = LookupService.getChannel(getBSystem(), getCChannel());
            rfc = LookupService.getRfcAccessor(chn);
            String req = "<ns0:TEST_NFE_MAIL_OPT xmlns:ns0='urn:sap-com:document:sap:rfc:functions'><I_ACCESS_KEY>" +
                idNFe + "<I_ACCESS_KEY></ns0:ZOTC_NFE_EMAIL_OUTPUT>";
            InputStream inputRFC = new ByteArrayInputStream(req.getBytes("UTF-8"));
            XmlPayload rfcPayload = LookupService.getXmlPayload(inputRFC);
            XmlPayload result = rfc.call(rfcPayload);
            InputStream resp = result.getContent();
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document doc = builder.parse(resp);
            Node node = (Node) doc.getElementsByTagName("E_EMAIL").item(0);
            if (node.hasChildNodes() && !node.getFirstChild().getNodeValue().equals("")) {
                email = node.getFirstChild().getNodeValue();
            }
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer transform = tf.newTransformer();
            Document docout = db.newDocument();
            Element root = docout.createElement("ns0:Mail");
            root.setAttribute("xmlns:ns0", "http://sap.com/xi/XI/Mail/30");
            docout.appendChild(root);
            Element subject = docout.createElement("Subject");
            root.appendChild(subject);
            Text subjectText = docout.createTextNode(getPrefixoSubject() + numeroNF);
            subject.appendChild(subjectText);
            Element from = docout.createElement("From");
            root.appendChild(from);
            Text fromText = docout.createTextNode(getEmailFrom());
            from.appendChild(fromText);
            if (email.length() > 0) {
                email += ";";
            } else {
                email = this.getEmaillist();
            }
            Element to = docout.createElement("To");
            root.appendChild(to);
            Text toText = docout.createTextNode(email);
            to.appendChild(toText);
            Element contentType = docout.createElement("Content_Type");
            root.appendChild(contentType);
            Text contentTypeText = docout.createTextNode("multipart/mixed;boundary=--AaZz");
            contentType.appendChild(contentTypeText);
            BodyText texto = new BodyText(idNFe, getFrase(), inptxml, pdf);
            Element content = docout.createElement("Content");
            root.appendChild(content);
            Text contentText = null;
            if ("NFE Company: ".equalsIgnoreCase(getPrefixoSubject())) {
                contentText = docout.createTextNode(texto.getnfeText());
            } else if ("NFE CANCELADA Company: ".equalsIgnoreCase(getPrefixoSubject())) {
                contentText = docout.createTextNode(texto.getCnfeText());
            } else if ("CCE Company: ".equalsIgnoreCase(getPrefixoSubject())) {
                contentText = docout.createTextNode(texto.getcceText());
            }
            content.appendChild(contentText);
            DOMSource domS = new DOMSource(docout);
            transform.transform((domS), 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 (SAXException 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;
}
private void configParamEmail() {
    setEmailFrom(NFe_Mail);
    setPrefixoDocumento(NFe);
    setPrefixoSubject(NFE_EMPRESA);
}
@Override
public void transform(TransformationInput in , TransformationOutput out) throws StreamTransformationException {
    this.execute( in .getInputPayload().getInputStream(), out.getOutputPayload().getOutputStream());
}
/*public void setParameter(Map arg0) {
// TODO Auto-generated method stub
}*/
公共类XmlNFe\u To\u邮件扩展了抽象转换{
私有字符串prefixoSubject=新字符串();
私有字符串emailFrom=新字符串();
私有字符串prefixoDocumento=新字符串();
私有字符串frase=新字符串();
私有字符串gap=“\n\r”;
私有AbstractTrace trace=null;
私有映射=null;
专用字符串BSSystem=“”;
专用字符串ComChannel=“”;
私人字符串=”;
私有最终字符串NFE_EMPRESA=“NFE公司:”;
私有最终字符串NFe=“NFe”;
专用最终字符串NFe_Mail=”nfe@company.com";
TransformationInput=null;
TransformationOutput=null;
public void execute(InputStream in,OutputStream out)抛出StreamTransformationException{
//TODO自动生成的方法存根
{
BSSystem=input.getInputParameters().getString(“BS_名称”);
ComChannel=input.getInputParameters().getString(“通道名称”);
Emails=input.getInputParameters().getString(“电子邮件”);
试一试{
configParameterMail();
BufferedReader inpxml=新的BufferedReader(新的InputStreamReader(in));
StringBuffer=新的StringBuffer();
字符串行=”;
字符串quebra=System.getProperty(“line.separator”);
而((line=inpxml.readLine())!=null){
行.replaceAll(“\r\n”,”);
行.replaceAll(quebra,“”);
行.replaceAll(“/>”和“/>”);
行.replaceAll(“/>”和“/>”);
行.replaceAll(“/>”和“/>”);
buffer.append(行);
}
字符串inptxml=buffer.toString();
inptxml=inptxml.replace(“\r\n”,”);
inptxml=inptxml.replaceAll(quebra,“”);
inptxml=inptxml.replaceAll(“/>”和“/>”);
inptxml=inptxml.replaceAll(“/>”和“/>”);
inptxml=inptxml.replaceAll(“/>”和“/>”);
字符串idNFe=“”;
字符串numerionf=“”;
字符串idEvent=“”;
idNFe=inptxml.substring(inptxml.indexOf(“”+7,inptxml.indexOf(“”));
numeroNF=idNFe.子串(25,34);
if(inptxml.indexOf(“infEvento”)>0{
idEvent=inptxml.substring(inptxml.indexOf(“”+10,inptxml.indexOf(“”));
if(idEvent.length()>0){
if(idEvent.equals(“111111”)){
this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll(“NFE”、“CancNFe”);
this.setPrefixoSubject(this.getPrefixoSubject().replaceAll(“NFE”,“NFE CANCELADA”));
}如果(idEvent.等于(“100000”)){
this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll(“NFE”、“CCE”);
this.setPrefixoSubject(this.getPrefixoSubject().replaceAll(“NFE”、“CCE”));
}否则{
this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll(“NFE”、“ManDest”);
this.setPrefixoSubject(this.getPrefixoSubject().replaceAll(“NFE”、“宣言”));
}
}
}
信道chn=null;
RfcAccessor rfc=null;
字符串email=“”;
字符串pdf=“”;
chn=LookupService.getChannel(getBSystem(),getCChannel());
rfc=LookupService.getRfcAccessor(chn);
String req=“”+
idNFe+”;
InputStream inputRFC=新的ByteArrayInputStream(请求getBytes(“UTF-8”));
XmlPayload rfcPayload=LookupService.getXmlPayload(inputfc);
XmlPayload result=rfc.call(rfcPayload);
InputStream resp=result.getContent();
DocumentBuilder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
文档doc=builder.parse(resp);
Node Node=(Node)doc.getElementsByTagName(“E_电子邮件”)。项(0);
if(node.hasChildNodes()&&!node.getFirstChild().getNodeValue()等于(“”){
email=node.getFirstChild().getNodeValue();
}
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db=dbf.newDocumentBuilder();
TransformerFactory tf=TransformerFactory.newInstance();
变压器变换=tf.newTransformer();
Document docout=db.newDocument();
Element root=docout.createElement(“ns0:Mail”);
setAttribute(“xmlns:ns0”http://sap.com/xi/XI/Mail/30");
appendChild(根目录);
元素主题=docout.createElement(“主题”);
root.appendChild(subject);
Text subjectText=docout.createTextNode(getPrefixoSubject()+numeroNF);
subject.appendChild(subjectText);
Element from=docout.createElement(“from”);
root.appendChild(from);
Text fromText=docout.createTextNode(getEmailFrom());
from.appendChild(fromText);
如果(email.length()>0){
电子邮件+=“;”;
}否则{
email=this.getEmaillist();
}
元素到=docout.createElement(
   TransformationInput input = null;               
   TransformationOutput output = null;