cancel
Showing results for 
Search instead for 
Did you mean: 

Erro geração e envio de E-mail B2B Outbound

Former Member
0 Kudos

Boa noite a todos,

Possuímos ambientes PI (7.30) e GRC NF-e (10.0) separados em instalações distintas. Todos os procedimentos de envio e retorno das NF-es com a SEFAZ estão operando normalmente. Porém, na implementação do cenário de Outbound B2B, estamos com o erro abaixo:

Java mapping com/tt/pi/nfe/b2b/NFeB2BMapping has thrown a StreamTransformationException.

Thrown: com.sap.aii.mapping.api.StreamTransformationException: while trying to invoke the method java.lang.Object.toString() of a null object loaded from local variable 'rfcDoc' at com.tt.pi.nfe.b2b.NFeB2BMapping.execute(NFeB2BMapping.java:215) at com.tt.pi.nfe.b2b.NFeB2BMapping.transform(NFeB2BMapping.java:50) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:92) 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:71) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:123)

Alguém já passou por situação semelhante ?

Abs,

Roger Vier

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Ola Todos,

    Problema Resolvido:

   - Nosso Communication Component é sem party, no entanto seguindo a dica do Henrique, resolvi alterar a chamada ao metodo getChanel() passando "*" no como PARTY. e tudo passou a funcionar.

    channel = LookupService.getChannel("*",ConfigurationHelper.BUS_SYSTEM_DEV, ConfigurationHelper.COMM_CHANNEL);


   Obrigado a todos pelo apoio.

   Abs.

Marco Dias.

rhviana
Active Contributor
0 Kudos

Que sacanagem !!

Boa Marco, parabéns .

Att,

R.Viana.

henrique_pinto
Active Contributor
0 Kudos

Mas veja como está o Receiver Agreement desse Comm Channel, deve estar com Party *.

Answers (3)

Answers (3)

Former Member
0 Kudos

Roger , nessa versão de PI da para utilizar tudo standard para fazer o B2B, sem java mappgin e udf.

Vc usa o RFC lookup standard + Mail Package que funciona na boa.

abs

Former Member
0 Kudos

Ola Ricardo,

   Obrigado pelo retorno, ja verificamos esta wiki... inclusive foi a base para nosso javamapping, a unica diferença aqui foi que utilizamos umas bibliotecas indicadas para o PI 7.3.

     

    A conversão de Stream para String ta fazendo certinho, conforme pode ser acompanhado no TRACE:

    O erro ocorre no LookUp Accessor, (  accessor = LookupService.getRfcAccessor(channel);  ) conforme descrito no fonte acima.

    Ja realizamos um check de toda a configuração tanto no ESR/ID/SLD .. como RFC.e esta OK.

     Ja comparei com outro cliente que utiliza essa solução com PI 7.31 e funciona perfeitamente... e esta td igual...

O erro ocorre neste ponto:

// Retrieve the communication channel                    channel=LookupService.getChannel(ConfigurationHelper.BUS_SYSTEM_DEV,ConfigurationHelper.COMM_CHANNEL);

                                                  trace.addWarning("Channel DEV " + channel);

                                                  // Get a RFC accessor for the channel

                                                  accessor = LookupService.getRfcAccessor(channel);

                                                  trace.addWarning("Accessor DEV " + accessor);

                                        }catch(Exception ex3){

                                                  trace.addInfo("ERRO Channel_Acessor");

    segue dados do trace... quem sabe estamos deixando escapar alguma coisa.


  <Trace level="1" type="T">*** START APPLICATION TRACE ***</Trace>

  <Trace level="2" type="T">JAVA Mapping Initial</Trace>

  <Trace level="2" type="T">JAVA Mapping Called</Trace>

  <Trace level="2" type="T">JAVA String</Trace>

  <Trace level="2" type="T">JAVA ConvertString</Trace>

  <Trace level="2" type="T">JAVA email</Trace>

  <Trace level="1" type="T">Dynamic Mail Started for 43130988818125000174550009900000361307558335</Trace>

  <Trace level="1" type="T">Dynamic Mail Started for 990000036</Trace>

  <Trace level="2" type="T">RFC Called</Trace>

  <Trace level="1" type="T">Channel PRD WAS_RFC_RCV (Party: , Service: APPLICATION_SYSTEM_PIP, Object ID: 1cd6f9e86583335685c46ee9f7e6860b)</Trace>

  <Trace level="1" type="T">Channel QAS WAS_RFC_RCV (Party: , Service: APPLICATION_SYSTEM_PID, Object ID: c82e121eda423bdab6d3a45c258b8ffa)</Trace>

  <Trace level="1" type="T">Channel DEV WAS_RFC_RCV (Party: , Service: APPLICATION_SYSTEM_PID, Object ID: c82e121eda423bdab6d3a45c258b8ffa)</Trace>

  <Trace level="2" type="T">ERRO Channel_Acessor</Trace>

  <Trace level="2" type="T">ERRO Channel_Acessor</Trace>

  <Trace level="1" type="T">Payload com.sap.aii.mapping.lookup.XmlPayload@50f1574e</Trace>

  <Trace level="1" type="T">java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.lookup.RfcAccessor.call(com.sap.aii.mapping.lookup.XmlPayload) of a null object loaded from local variable 'accessor'</Trace>

  <Trace level="1" type="T">Erro: java.lang.NullPointerException: while trying to invoke the method java.lang.Object.toString() of a null object loaded from local variable 'rfcDoc'</Trace>

  <Trace level="1" type="T">*** END APPLICATION TRACE ***</Trace>

rhviana
Active Contributor
0 Kudos

Marco bom dia,

Pergunta por curiosidade:


Por que você está utilizando duas vezes os metodos de Strem:

    transform - 7.0>

   public void transform(TransformationInput arg0, TransformationOutput arg1)

                              throws StreamTransformationException {

   e depois esta chamando o

    execute - 7.1<

    public void execute(InputStream in, OutputStream out)

                              throws StreamTransformationException {

Por que não resolve tudo via transform ?

Você já conseguiu capturar o Stream aqui

InputStream in = null;

OutputStream out = null;

in =arg0.getInputPayload().getInputStream();

out =arg1.getOutputPayload().getOutputStream();

-----------------------------------------------------------------------------------------

Trace

Na realidade está visivel que o problema só ocorreu com 2 canais:

  <Trace level="1" type="T">Channel PRD WAS_RFC_RCV (Party: , Service: APPLICATION_SYSTEM_PIP, Object ID: 1cd6f9e86583335685c46ee9f7e6860b)</Trace>

  <Trace level="1" type="T">Channel QAS WAS_RFC_RCV (Party: , Service: APPLICATION_SYSTEM_PID, Object ID: c82e121eda423bdab6d3a45c258b8ffa)</Trace>

  <Trace level="1" type="T">Channel DEV WAS_RFC_RCV (Party: , Service: APPLICATION_SYSTEM_PID, Object ID: c82e121eda423bdab6d3a45c258b8ffa)</Trace>

  <Trace level="2" type="T">ERRO Channel_Acessor</Trace>

  <Trace level="2" type="T">ERRO Channel_Acessor</Trace>

Verifica o estado dos canais QAS WAS_RFC_RCV e DEV WAS_RFC_RCV

- Usuario bloqueado, hostname errado etc....

Aumenta o nível do trace para 3 - sxmb_adm !

Coloca isso tambem no codigo:

trace.addInfo("ERRO Channel_Acessor no canal "+ acessor);

Para saber exatamente qual canal está dando zica !

-------------------------------------------------------------

Vou convocar a equipe sinistra para tentar ajudar também.

, Former Member

Alguma sugestão senhores ?

Valeu,

Atenciosamente,

Viana.

Former Member
0 Kudos

Ola Ricardo,

    Mais uma vez, obrigado pelo retorno,

     sobre suas perguntas "Pergunta por curiosidade:

                                          Por que você está utilizando duas vezes os metodos de Strem:"

     então, este codigo era usado para a versão anterior a 7.1... qdo fui aplicar na 7.3 aproveitei este codigo e fiz algumas "correções" pra fazer funcionar... e depois iria arrumar decentemente... só que esse "depois" ainda não chegou.... falta de tempo mesmo rsrsrsrs.. mas está funcionando deste mesmo jeito em outros clientes perfeitamente.

     Sobre os demais itens, também tenho a impressão que o problema seja no canal de comunicação (no caso DEV/QAS) que são os mesmos..ou alguma coisa que esteja impedindo o PI chegar até a função RFC no GRC

     no monitor o canal de comunicação WAS_RFC_RCV aparece ativo e sem erro.

   . chequei varais vezes. config e objetos no lado PI, bem como RFC(FM) e user no lado GRC.. inclusive refazendo tudo do zero...

   uma unica coisa que estou achando estranho (mas ai creio que seja apelação da minha parte) é que o algumas coisas no PI esta sempre rodando como idioma Alemão... mesmo qdo efetuo o Login com o ingles ou PT...e como o Software component que criamos esta setado para Language EN ou PT... estou pedindo pro basis verificar se tem alguma coisa errada ai... 

desde ja obrigado.

rhviana
Active Contributor
0 Kudos

Marco,

Nesse caso se funcionava na versão 7.1, você já deveria estar utilizando a lib do PI "com.sap.xpi.ib.mapping.lib.jar" supostamente deveria funcionar na 7.3.

Bom sobre a linguagem etc... fala com basis isso é erro dele hehe..

Sobre a conexão, por que você não cria uma nova com outro nome e testa novamente ? Pode ser problema de cache também.

Valeu.

Abracos,

Viana.

henrique_pinto
Active Contributor
0 Kudos

O método .getChannel() está retornando null para a combinacao de valores de Business System/Service & Channel name que vc passou.

Note que esse método tb tem uma versao com 3 parametros, onde vc passa tb o nome da Party.

Verifique no configuration, se no seu caso nao tem tb Party ou se ele realmente está criado sem Party.

Se estiver, tem q adicionar à chamada.

E, claro, verifique tb os valores de Business System e Channel Name que estão sendo configurados nessa classe ConfigurationHelper, se estao batendo exatamente com o seu Configuration.


Abs,

Henrique.

rhviana
Active Contributor
0 Kudos

Amigão,

Resolveu ai ?

Nunca mais postou nada.

Se case resolveu, reward points e feche a thread

Abracos,

Ricardo Viana.

Former Member
0 Kudos

Olá Ricardo !

Enviamos para a SAP. Estamos aguardando o retorno e a resolução para postarmos aqui no Fórum.

Valeu pelas dicas.

Abs,

Roger Vier

rhviana
Active Contributor
0 Kudos

Roger bom dia,

Já teve alguma posição ?

Posso ajudar em algo ?

Atenciosamente,

Viana.

former_member182114
Active Contributor
0 Kudos

Bom dia Roger,

O que tem dentro desse NFeB2BMapping.java que implementaram?

Está faltando tratamento para evitar nulos, talvez seja por alguma chamada RFC Lookup para pegar o email destinatário, ou então lendo a tag de email.

Pode colar o código aqui?

Atenciosamente, Fernando Da Rós

Former Member
0 Kudos

Olá Fernando,

Segue abaixo o Java Mapping:

package com.tt.pi.nfe.b2b;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.io.BufferedReader;

//import java.util.HashMap;

//import java.util.Map;

//import java.io.ByteArrayInputStream;

//import java.io.ByteArrayOutputStream;

//import java.io.Reader;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.transform.OutputKeys;

import javax.xml.transform.Transformer;

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 sun.misc.BASE64Encoder;

import com.sap.aii.mapping.api.AbstractTrace;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

import com.sap.aii.mapping.api.StreamTransformationException;

//import com.sap.aii.mapping.api.StreamTransformationConstants;

import com.tt.pi.nfe.b2b.helper.*;

public class NFeB2BMapping extends AbstractTransformation  {

          private AbstractTrace trace = null;

          private String prefixoSubject = new String();

          private String emailFrom = new String();

          private String prefixoDocumento = new String();

          public void transform(TransformationInput arg0, TransformationOutput arg1) 

                              throws StreamTransformationException {

                    trace = (AbstractTrace) getTrace();

                    trace.addInfo("JAVA Mapping Initial");

                    this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream()); 

          } 

          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 void execute(InputStream in, OutputStream out) 

                              throws StreamTransformationException { 

                    trace.addInfo("JAVA Mapping Called");

                    try{

                              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

                              DocumentBuilder builder=factory.newDocumentBuilder();

                              Document documentIn = null;

                              Document documentOut = null;

                              BASE64Encoder encoder = new BASE64Encoder();

                              String inputString = "";

                              String id = "";

                              String attachmentName = "";

                              String idNFe = "";

                              String numeroNF = "";

                              String sEmailTo = "";

                              String sEmailFrom = "";

                              String sEmailTransp = "";

                              String sSubject = "";

 

                              //Transforma mensagem em entrada em string ----INICIO

                              trace.addInfo("JAVA String");

                              BufferedReader inpxml = new BufferedReader(new InputStreamReader(in));

                              StringBuffer buffer = new StringBuffer();

                              String line = "";

                              while ((line = inpxml.readLine()) != null) {

                                        buffer.append(line);

                              }

                              String inptxml = buffer.toString();

                              // Generate input String

                              trace.addInfo("JAVA ConvertString");

                              inputString = GeneralHelper.streamToString(in);

                              // ***WARNING***: The input string MUST be preserved. Any changes

                              // will invalidade the signature in the XML file. This string will be

                              // used as the XML content for the attachment file.

 

                              //Obtendo dados para o envio de e-mail

                              trace.addInfo("JAVA email" );

                              idNFe = inptxml.substring(inptxml.indexOf("<chNFe>")+7,inptxml.indexOf("</chNFe>"));

                              trace.addWarning("Dynamic Mail Started for " + idNFe);

                              numeroNF = idNFe.substring(25,34);

                              trace.addWarning("Dynamic Mail Started for " + numeroNF);

                              if ( inptxml.indexOf("infEvento") > 0){

                                        this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll("NFE", "CCE"));

                                        this.setPrefixoSubject(this.getPrefixoSubject().replaceAll("NFE", "CCE"));

                              }

                              if ( inptxml.indexOf("infCanc") > 0){

                                        this.setPrefixoDocumento(this.getPrefixoDocumento().replaceAll("NFE", "CancNFe"));

                                        this.setPrefixoSubject(this.getPrefixoSubject().replaceAll("NFE", "NFE CANCELADA"));

                              }

                              // Attachment Name

                              id = idNFe;

                              attachmentName = id + "-nfe.xml";

                              // Execute RFC for B2B Mail parameters

                              trace.addInfo("RFC Called");

                              Document rfcDoc = LookupServiceHelper.executeNFeRFC(id, getTrace());

                              trace.addWarning(rfcDoc.toString());

                              try {

                                        Node mailFrom = (Node) rfcDoc.getElementsByTagName("MAIL_FROM").item(0);

                                        if (mailFrom.hasChildNodes() && !mailFrom.getFirstChild().getNodeValue().equals("")) {

                                                  sEmailFrom = mailFrom.getFirstChild().getNodeValue();

                                        }

                                        Node mailTo = (Node) rfcDoc.getElementsByTagName("MAIL_TO").item(0);

                                        if (mailTo.hasChildNodes() && !mailTo.getFirstChild().getNodeValue().equals("")) {

                                                  sEmailTo = mailTo.getFirstChild().getNodeValue();

                                        }

                                        Node mailTransp = (Node) rfcDoc.getElementsByTagName("MAIL_TRANSP").item(0);

                                        if (mailTransp.hasChildNodes() && !mailTransp.getFirstChild().getNodeValue().equals("")) {

                                                  sEmailTransp = mailTransp.getFirstChild().getNodeValue();

                                        }

                                        Node nSubject = (Node) rfcDoc.getElementsByTagName("SUBJECT").item(0);

                                        if (nSubject.hasChildNodes() && !nSubject.getFirstChild().getNodeValue().equals("")) {

                                                  sSubject = nSubject.getFirstChild().getNodeValue();

                                                  sSubject = sSubject.replaceAll("&", "NF-e " + id);

                                        }

                              } catch (Exception e) {

                                        trace.addWarning("RFC return read failed! Exception: " + e);

                              }

                              // Generate output document

                              trace.addInfo("JAVA Generate DocOut");

                              documentOut = builder.newDocument();

                              Element rootNode = documentOut.createElementNS("http://sap.com/xi/XI/Mail/30", "ns1:Mail");

                              documentOut.appendChild(rootNode);

                              Element eSubject = documentOut.createElement("Subject");

                              rootNode.appendChild(eSubject);

                              GeneralHelper.createTextValue(eSubject, sSubject, documentOut);

                              Element eFrom = documentOut.createElement("From");

                              rootNode.appendChild(eFrom);

                              GeneralHelper.createTextValue(eFrom, sEmailFrom, documentOut);

                              Element eTo = documentOut.createElement("To");

                              rootNode.appendChild(eTo);

                              if (sEmailTransp != null && sEmailTransp != "" && !sEmailTransp.equals(sEmailTo))

                                        GeneralHelper.createTextValue(eTo, sEmailTo+"; "+sEmailTransp, documentOut);

                              else

                                        GeneralHelper.createTextValue(eTo, sEmailTo, documentOut);

                              String sContentType = "multipart/mixed; boundary=\"--ZZ\"";

                              Element eContentType = documentOut.createElement("Content_Type");

                              rootNode.appendChild(eContentType);

                              GeneralHelper.createTextValue(eContentType, sContentType, documentOut);

                              String boundary = "--ZZ";

                              String CRLF = "\r\n";

                              String sContent = "";

                              sContent = "--" + boundary + CRLF

                                                  + "Content-Type: text/html; charset=UTF-8" + CRLF

                                                  + "Content-Disposition: inline" + CRLF + CRLF

                                                  + ConfigurationHelper.MSG_MAIL_BODY_NFE + CRLF

                                                  + "--" + boundary + CRLF

                                                  + "Content-Type: application/xml; name=" + attachmentName + CRLF

                                                  + "Content-Disposition: attachment; filename=" + attachmentName + CRLF

                                                  + "Content-Transfer-Encoding: base64" + CRLF + CRLF

                                                  + encoder.encode(inptxml.getBytes("UTF-8"));

                              Element eContent = documentOut.createElement("Content");

                              rootNode.appendChild(eContent);

                              eContent.appendChild(documentOut.createCDATASection(sContent));

                              TransformerFactory tf = TransformerFactory.newInstance();

                              Transformer transform = tf.newTransformer();

                              transform.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");

                              transform.transform(new DOMSource(documentOut), new StreamResult(out));

                    }catch (Throwable t) {

                              trace.addWarning("Erro: " + t.toString());

                              throw new StreamTransformationException(t.getMessage(), t);

                    }

          }

 

          public static void main(String args[]) {

                    //                    try

                    //                    {

                    //

                    //                              String xml = "";

                    //

                    //                              ByteArrayInputStream inStream = new ByteArrayInputStream(xml.getBytes());

                    //                              OutputStream outStream = new ByteArrayOutputStream();

                    //

                    //                  NFeB2BMapping mapping = new NFeB2BMapping();

                    //                  try{

                    //                            mapping.execute(inStream,outStream);

                    //                              }catch (Exception ex){

                    //                                        ex.printStackTrace();

                    //                              }

                    //                    }

                    //                    catch (Exception e)                    {

                    //                              e.printStackTrace();

                    //                    }

          }

          //           @Override

}

Segue também o código do Lookup service:

package com.tt.pi.nfe.b2b.helper;

import java.io.ByteArrayInputStream;

import java.io.InputStream;

import java.util.Iterator;

import java.util.Map;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import com.sap.aii.mapping.api.AbstractTrace;

import com.sap.aii.mapping.lookup.Channel;

import com.sap.aii.mapping.lookup.DataBaseAccessor;

import com.sap.aii.mapping.lookup.DataBaseResult;

import com.sap.aii.mapping.lookup.LookupService;

import com.sap.aii.mapping.lookup.RfcAccessor;

import com.sap.aii.mapping.lookup.XmlPayload;

public class LookupServiceHelper {

 

          public static Document executeNFeRFC(String idNFe, AbstractTrace trace){

                    return executeRFC("<ns0:ZNFE_GRC10_B2B_GET_MAIL_BY_ID xmlns:ns0='urn:sap-com:document:sap:rfc:functions'><ID>" + idNFe + "</ID></ns0:ZNFE_GRC10_B2B_GET_MAIL_BY_ID>", trace);

          }

          private static Document executeRFC(String messageRFC, AbstractTrace trace) {

                    Channel channel = null;

                    RfcAccessor accessor = null;

                    try{

                              // Retrieve the communication channel

                              channel = LookupService.getChannel(ConfigurationHelper.BUS_SYSTEM_PRD, ConfigurationHelper.COMM_CHANNEL);

                              trace.addWarning("Channel PRD " + channel);

                              // Get a RFC accessor for the channel

                              accessor = LookupService.getRfcAccessor(channel);

                              trace.addWarning("Accessor PRD " + accessor);

                    }catch (Exception ex1){

                              try{

                                        // Retrieve the communication channel

                                        channel = LookupService.getChannel(ConfigurationHelper.BUS_SYSTEM_QAS, ConfigurationHelper.COMM_CHANNEL);

                                        trace.addWarning("Channel QAS " + channel);

                                        // Get a RFC accessor for the channel

                                        accessor = LookupService.getRfcAccessor(channel);

                                        trace.addWarning("Accessor QAS " + accessor);

                              }catch(Exception ex2){

                                        try{

                                                  // Retrieve the communication channel

                                                  channel = LookupService.getChannel(ConfigurationHelper.BUS_SYSTEM_DEV, ConfigurationHelper.COMM_CHANNEL);

                                                  trace.addWarning("Channel DEV " + channel);

                                                  // Get a RFC accessor for the channel

                                                  accessor = LookupService.getRfcAccessor(channel);

                                                  trace.addWarning("Accessor DEV " + accessor);

                                        }catch(Exception ex3){

                                                  trace.addInfo("ERRO Channel_Acessor");

                                        }

                              }

                    }

 

 

                    try {

                              // Create the xml inputstream

                              byte[] bytes = messageRFC.getBytes("UTF-8");

                              InputStream stream = new ByteArrayInputStream(bytes);

                              // Create xml payload

                              XmlPayload payload = LookupService.getXmlPayload(stream);

                              trace.addWarning("Payload " + payload);

                              // Execute lookup

                              XmlPayload result = accessor.call(payload);

                              trace.addWarning("Result " + result);

                              // Get the response

                              InputStream resp = result.getContent();

                              trace.addWarning("Response " + resp);

                              // Parse the response

                              DocumentBuilder rfcBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

 

                              //Document rfcDoc = rfcBuilder.parse(resp);

                              return rfcBuilder.parse(resp);

                    }

                    catch(Exception ex) {

                              trace.addWarning(ex.toString());

                              return null;

                    }

          }

 

          private static String executeQuery(String query, String service, String cc){

                    Channel channel = null;

                    DataBaseAccessor accessor = null;

                    DataBaseResult resultSet = null;

                    try {

                              // Set channel according to Directory config

                              channel = LookupService.getChannel(service, cc);

                              // Set database accessor

                              accessor = LookupService.getDataBaseAccessor(channel);

                              // Execute query and get resultset

                              resultSet = accessor.execute(query.toString());

                              Iterator it = resultSet.getRows();

                              while (it.hasNext()) {

                                        Map rowMap = (Map) it.next();

                                        return rowMap.values().toArray()[0] + "";

                              }

                              return "-1";

                    } catch (Exception e1) {

                              return "error : " +  e1.getMessage();

                    } finally {

                              try {

                                        if (accessor != null)

                                                  accessor.close();

                              } catch (Exception e2) {

                                        return "error";

                              }

                    }

          }

}

Nos parece que o erro está acontecendo nessa parte do código:

// Retrieve the communication channel

                                                  channel = LookupService.getChannel(ConfigurationHelper.BUS_SYSTEM_DEV, ConfigurationHelper.COMM_CHANNEL);

                                                  trace.addWarning("Channel DEV " + channel);

                                                  // Get a RFC accessor for the channel

                                                  accessor = LookupService.getRfcAccessor(channel);

                                                  trace.addWarning("Accessor DEV " + accessor);

                                        }catch(Exception ex3){

                                                  trace.addInfo("ERRO Channel_Acessor");

Obrigado pela ajuda.

Abs,

Roger Vier

Former Member
0 Kudos

Fernando,

Tb estou enviando em anexo, o trace da mensagem.

Obrigado,

Roger Vier

rhviana
Active Contributor
0 Kudos

Roger boa tarde,

Amigão da uma olhada na minha wiki.

http://155.56.92.22/wiki/pages/viewpage.action?pageId=315524420

Acredito que ela vai te ajudar, alias o codigo está bem parecido com o da wiki...,

voce deve estar fazendo a conversão de Stream para String errado, voce deve estar tentando converter utilizando .toString() algo nulo.

                              Document rfcDoc = LookupServiceHelper.executeNFeRFC(id, getTrace());

                              if(rfcDoc == null)

                                  absTraceLog.addDebugMessage("Variavel rfcDoc está null");

                             else{

                                 String algo = rfcDoc.toString();

                                 absTraceLog.addDebugMessage( "Variavel algo = "+ algo.toString());

                              }

"java.lang.Object.toString() of a null"

Abracos,

Viana.

Message was edited by: Ricardo Vian