Sending NFe to MG in Version 3.10

1

After the tips I changed the code of the method as well as applied the corrections in the web service changing from:

System.Xml.Serialization.XmlArrayItemAttribute("retEnviNFe", IsNullable:=False)

To:

System.Xml.Serialization.XmlArrayItemAttribute("retEnviNFe", [Namespace]:="http://www.portalfiscal.inf.br/nfe", IsNullable:=False)

In the meantime I get an empty object as a return. My God, what's wrong?
Has anyone had success in sending (3.10) to MG?
Here's the changed method:

        Public Function enviaNFe_(ByVal NumeroDoLote As Integer, ByVal ListiView As ListView, ByVal Label As ToolStripStatusLabel) As Boolean
    Dim ret As Boolean = False
    Dim result() As String
    Dim xmlDoc As XmlDocument = Nothing
    Dim arquivoRetorno As String = Nothing

    Try
        'vrifica a existência do arquivo
        If File.Exists(Me.ArquivoXml) = True Then

            Me.labelMsg.Visible = True
            Me.labelMsg.Text = Space(40) & "Aguarde um instante por Favor. Enviando o arquivo...."
            My.Application.DoEvents()

            'Carrega o arquivo xml para dentro do objeto xmlDoc
            xmlDoc = New XmlDocument
            xmlDoc.Load(Me.ArquivoXml)
            'Cria um objeto XmlNode
            Dim oNode As XmlNode = xmlDoc.DocumentElement

            'Seleciona o certificado digital e devolve o xml assinado
            If Me.SelecionarCertificado = True Then

                'Define o cabeçalho
                Dim NFeCabecMsg As pNfeAutorizacao3.nfeCabecMsg = New pNfeAutorizacao3.nfeCabecMsg
                With NFeCabecMsg
                    .cUF = "31"
                    .versaoDados = "3.10"
                End With

                'Dados da NFe
                Dim NFeDadosMsg As pNfeAutorizacao3.nfeDadosMsg = New pNfeAutorizacao3.nfeDadosMsg
                NFeDadosMsg.Any = New XmlNode() {xmlDoc}
                NFeDadosMsg.Any(0) = oNode

                'Envia o arquivo .xml (Consome o WS)
                Dim oWS_pNFeAutorizacao3 As pNfeAutorizacao3.NfeAutorizacao = New pNfeAutorizacao3.NfeAutorizacao
                With oWS_pNFeAutorizacao3
                    .Url = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeAutorizacao.asmx"
                    .nfeCabecMsgValue = NFeCabecMsg
                    .Timeout = 50000
                    .ClientCertificates.Add(Me.X509Cert)
                    .SoapVersion = Web.Services.Protocols.SoapProtocolVersion.Soap12
                    result = New String() {.NfeAutorizacaoLote(NFeDadosMsg).ToString}
                End With
            End If
        End If

        '...aqui eu trataria o retorno (result)
    Catch ex As Exception
        MessageBox.Show("Erro no envio da NFe.", "Gestor .NET" & vbNewLine & ex.ToString, MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
End Function
    
asked by anonymous 28.02.2015 / 23:40

2 answers

1

A way to get in string: result(0)(0).OwnerElement.OuterXml , then just convert to XML . In this case it is in the return of the ProtocolReferenceNFe MG .

    
30.05.2018 / 22:31
0

It seems like you're only having trouble reading the value of this variable.

In my case, I did this and managed to get the feedback.

    Dim result As Object
    result = servidor.consultaCadastro2(cabecalho, dados)

    MsgBox(result(0)(2).OuterXml)

The hardest part was finding out that the MG server was in trouble. What I think is absurd.

    
07.07.2016 / 14:35