1
After the tips I changed the method code as well as applied the fixes in the web service changing from:
System.Xml.Serialization.XmlArrayItemAttribute("retEnviNFe", IsNullable:=False)
for:
System.Xml.Serialization.XmlArrayItemAttribute("retEnviNFe", [Namespace]:="http://www.portalfiscal.inf.br/nfe", IsNullable:=False)
However I receive as return an empty object. My God what is wrong?
Someone has already succeeded in sending (3.10) to MG?
Follow the modified 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
Are you sure? Have you found here (http://answall.com/questions/50629/retorno-authorization%C3%A7%C3%A3o-nfe-3-10-mg-c/50720#50720) that the return is an object and not a string? @yelar
– rubStackOverflow
Yes, the return is 'System.Object()' type, but assuming that everything in . net is an object when I do ". Nfeautorizacaolote(Nfedadosmsg). Tostring" if there was any information it would not be converted to a string object? The problem is that it returns a System.Object() with no values. The return looks like this: result {Lenght=1} (0) "System.Object[]". Could you if possible post or send an email showing how to pick up this return? Sorry, I hope I’m not abusing.
– YELAR
Take this example: http://1drv.ms/1EFJESd @yelar
– rubStackOverflow