CLASSES DA NFE 4.00
Alguém conseguiu gerar as Classes? estou tentando gerar as Classes pelo XSD.exe
mais esta dando muitos erros na classe que gerei
ou eu gerei a classe errada mesmo
gerei essa clase para consultar o serviço
mais esta dando muitos erros na classe que gerei
ou eu gerei a classe errada mesmo
gerei essa clase para consultar o serviço
[ô]------------------------------------------------------------------------------
[ô] <auto-generated>
[ô] This code was generated by a tool.
[ô] Runtime Version:4.0.30319.1
[ô]
[ô] Changes to this file may cause incorrect behavior and will be lost if
[ô] the code is regenerated.
[ô] </auto-generated>
[ô]------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization
[ô]
[ô]This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.1.
[ô]
Namespace StatusSP
[ô][ô][ô]<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.Web.Services[Ô], [Ô]4.0.30319.1[Ô]), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute([Ô]code[Ô]), _
System.Web.Services.WebServiceBindingAttribute(Name:=[Ô]NfeStatusServico4Soap[Ô], [Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> _
Partial Public Class NfeStatusServico4
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
Private nfeStatusServicoNFOperationCompleted As System.Threading.SendOrPostCallback
Private useDefaultCredentialsSetExplicitly As Boolean
[ô][ô][ô]<remarks/>
Public Sub New(ByVal v_URL As String)
MyBase.New()
Me.Url = v_URL [ô]Global.WindowsApplication1.My.MySettings.Default.WindowsApplication5_StatusRS_NfeStatusServico4
If (Me.IsLocalFileSystemWebService(Me.Url) = True) Then
Me.UseDefaultCredentials = True
Me.useDefaultCredentialsSetExplicitly = False
Else
Me.useDefaultCredentialsSetExplicitly = True
End If
End Sub
Public Shadows Property Url() As String
Get
Return MyBase.Url
End Get
Set(ByVal value As String)
If (((Me.IsLocalFileSystemWebService(MyBase.Url) = True) _
AndAlso (Me.useDefaultCredentialsSetExplicitly = False)) _
AndAlso (Me.IsLocalFileSystemWebService(value) = False)) Then
MyBase.UseDefaultCredentials = False
End If
MyBase.Url = value
End Set
End Property
Public Shadows Property UseDefaultCredentials() As Boolean
Get
Return MyBase.UseDefaultCredentials
End Get
Set(ByVal value As Boolean)
MyBase.UseDefaultCredentials = value
Me.useDefaultCredentialsSetExplicitly = True
End Set
End Property
[ô][ô][ô]<remarks/>
Public Event nfeStatusServicoNFCompleted As nfeStatusServicoNFCompletedEventHandler
[ô][ô][ô]<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute([Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF[Ô], Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
Public Function nfeStatusServicoNF(<System.Xml.Serialization.XmlElementAttribute([Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> ByVal nfeDadosMsg As System.Xml.XmlNode) As <System.Xml.Serialization.XmlElementAttribute([Ô]nfeResultMsg[Ô], [Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô], IsNullable:=True)> System.Xml.XmlNode
Dim results() As Object = Me.Invoke([Ô]nfeStatusServicoNF[Ô], New Object() {nfeDadosMsg})
Return CType(results(0), System.Xml.XmlNode)
End Function
[ô][ô][ô]<remarks/>
Public Overloads Sub nfeStatusServicoNFAsync(ByVal nfeDadosMsg As System.Xml.XmlNode)
Me.nfeStatusServicoNFAsync(nfeDadosMsg, Nothing)
End Sub
[ô][ô][ô]<remarks/>
Public Overloads Sub nfeStatusServicoNFAsync(ByVal nfeDadosMsg As System.Xml.XmlNode, ByVal userState As Object)
If (Me.nfeStatusServicoNFOperationCompleted Is Nothing) Then
Me.nfeStatusServicoNFOperationCompleted = AddressOf Me.OnnfeStatusServicoNFOperationCompleted
End If
Me.InvokeAsync([Ô]nfeStatusServicoNF[Ô], New Object() {nfeDadosMsg}, Me.nfeStatusServicoNFOperationCompleted, userState)
End Sub
Private Sub OnnfeStatusServicoNFOperationCompleted(ByVal arg As Object)
If (Not (Me.nfeStatusServicoNFCompletedEvent) Is Nothing) Then
Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg, System.Web.Services.Protocols.InvokeCompletedEventArgs)
RaiseEvent nfeStatusServicoNFCompleted(Me, New nfeStatusServicoNFCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState))
End If
End Sub
[ô][ô][ô]<remarks/>
Public Shadows Sub CancelAsync(ByVal userState As Object)
MyBase.CancelAsync(userState)
End Sub
Private Function IsLocalFileSystemWebService(ByVal url As String) As Boolean
If ((url Is Nothing) _
OrElse (url Is String.Empty)) Then
Return False
End If
Dim wsUri As System.Uri = New System.Uri(url)
If ((wsUri.Port >= 1024) _
AndAlso (String.Compare(wsUri.Host, [Ô]localHost[Ô], System.StringComparison.OrdinalIgnoreCase) = 0)) Then
Return True
End If
Return False
End Function
End Class
[ô][ô][ô]<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.Web.Services[Ô], [Ô]4.0.30319.1[Ô])> _
Public Delegate Sub nfeStatusServicoNFCompletedEventHandler(ByVal sender As Object, ByVal e As nfeStatusServicoNFCompletedEventArgs)
[ô][ô][ô]<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.Web.Services[Ô], [Ô]4.0.30319.1[Ô]), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute([Ô]code[Ô])> _
Partial Public Class nfeStatusServicoNFCompletedEventArgs
Inherits System.ComponentModel.AsyncCompletedEventArgs
Private results() As Object
Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object)
MyBase.New(exception, cancelled, userState)
Me.results = results
End Sub
[ô][ô][ô]<remarks/>
Public ReadOnly Property Result() As System.Xml.XmlNode
Get
Me.RaiseExceptionIfNecessary()
Return CType(Me.results(0), System.Xml.XmlNode)
End Get
End Property
End Class
End Namespace
e tento consultar o Serviço assim
mais esta dando erro de SOAP
Public Function ConsultaStatusWs(ByVal xStatus_N_UF As String, ByVal txFormaEmissao As String) As RetRetorno
Dim strRetorno As XmlElement
Dim CERT As X509Certificate2
[ô]BUSCA CERTIFICADOS
If Trim(TxtCertificado.Text) <> [Ô][Ô] Then
Dim CERT1 As New X509Certificate2(TxtCertificado.Text, TxtSenha.Text)
CERT = CERT1
Else
CERT = SelecionarCertificado([Ô][Ô])
End If
Try
Dim wsMsg As StatusSP.NfeStatusServico4
wsMsg = New StatusSP.NfeStatusServico4(TxtURL.Text)
wsMsg.Timeout = 100000
wsMsg.ClientCertificates.Add(CERT)
System.Net.ServicePointManager.SecurityProtocol = DirectCast(3072, System.Net.SecurityProtocolType) [ô]tsl 1.2
Dim dados As XmlDocument = New XmlDocument
dados.LoadXml([Ô]<?xml version=[Ô][Ô]1.0[Ô][Ô] encoding=[Ô][Ô]UTF-8[Ô][Ô]?><consStatServ versao=[Ô][Ô]4.00[Ô][Ô] xmlns=[Ô][Ô]http://www.portalfiscal.inf.br/nfe[Ô][Ô]><tpAmb>2</tpAmb><cUF>[Ô] & UF_N(xStatus_N_UF) & [Ô]</cUF><xServ>STATUS</xServ></consStatServ>[Ô])
strRetorno = wsMsg.nfeStatusServicoNF(dados)
Dim Retornos As New RetRetorno
Retornos.L_Retornos = New List(Of RetRecibo)
Dim VarRecibo As New RetRecibo
For Each outerNode As XmlNode In strRetorno
If (outerNode.Name = [Ô]tpAmb[Ô]) Then
Retornos.tpAmb = outerNode.InnerText
End If
If (outerNode.Name = [Ô]verAplic[Ô]) Then
Retornos.verAplic = outerNode.InnerText
End If
If (outerNode.Name = [Ô]nRec[Ô]) Then
Retornos.nRec = outerNode.InnerText
End If
If (outerNode.Name = [Ô]cStat[Ô]) Then
Retornos.cStat = outerNode.InnerText
End If
If (outerNode.Name = [Ô]xMotivo[Ô]) Then
Retornos.xMotivo = outerNode.InnerText
End If
If (outerNode.Name = [Ô]cUF[Ô]) Then
Retornos.cUF = outerNode.InnerText
End If
For Each InnerNode As XmlNode In outerNode.ChildNodes
[ô]SE O NOME DO NO FOR infProt ENTRA NO MESMO
If InnerNode.Name = [Ô]infProt[Ô] Then
[ô]PEGA A VARIAVEL ID QUE é UM ATRIBUTO E NAO UM ITEM
VarRecibo.Id = [Ô][Ô] [ô]InnerNode.Attributes.ItemOf([Ô]Id[Ô]).InnerText
[ô]PERCORRE CAMPOS DO RETORNO PARA CAPTURAR AS INFORMAÇÕES
For Each InnerNode2 As XmlNode In InnerNode.ChildNodes
If (InnerNode2.Name = [Ô]tpAmb[Ô]) Then
VarRecibo.tpAmb = InnerNode2.InnerText
End If
If (InnerNode2.Name = [Ô]verAplic[Ô]) Then
VarRecibo.verAplic = InnerNode2.InnerText
End If
If (InnerNode2.Name = [Ô]chNFe[Ô]) Then
VarRecibo.chNFe = InnerNode2.InnerText
End If
If (InnerNode2.Name = [Ô]dhRecbto[Ô]) Then
VarRecibo.dhRecbto = InnerNode2.InnerText
End If
If (InnerNode2.Name = [Ô]digVal[Ô]) Then
VarRecibo.digVal = InnerNode2.InnerText
End If
If (InnerNode2.Name = [Ô]cStat[Ô]) Then
VarRecibo.cStat = InnerNode2.InnerText
End If
If (InnerNode2.Name = [Ô]xMotivo[Ô]) Then
VarRecibo.xMotivo = InnerNode2.InnerText
End If
Next
[ô]ADICIONA A NOTA NA LISTA DE RETORNO
Retornos.L_Retornos.Add(VarRecibo)
End If
Next
Next
Return Retornos
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, [Ô][Ô])
Return Nothing
End Try
End Function
mais esta dando erro de SOAP
Fiz isso num tópico outro dia.
Citação::
Fiz isso num tópico outro dia.
Ola Kerplunk tudo bem?
pelo que entendi voce usou a Classe NFe-4_00 estou tentando fazer a consulta do Serviço
não achei Esse Tread na Classe que você postou
mais como voce gerou essa Classe?
Essa é a thread onde mostro como são geradas as classes com a ferramenta XSD.
Citação::
Essa é a thread onde mostro como são geradas as classes com a ferramenta XSD.
Cara eu to mais perdido que cego em tiroteio
tente gerar a Classe de consulta usado [ô]c:\xsd_nfe\consStatServ_v4.00.xsd /l:vb /c /out:c:\shema[ô]
blx o XSD criou a Classe
mais não consigo instanciar a Classe
a Classe não recebia o Certificado Digital até ai BLZ
adicionei
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
a classe e consegui colocar o certificado digital
mais não consigo abrir o canal de comunicação com o WebService
estou tentando assim
Dim wsMsg As StatusNfe.NfeStatusServico4
wsMsg = New StatusNfe.NfeStatusServico4(TxtURL.Text)
wsMsg.Timeout = 100000
wsMsg.ClientCertificates.Add(CERT)
System.Net.ServicePointManager.SecurityProtocol = DirectCast(3072, System.Net.SecurityProtocolType) [ô]tsl 1.2
Dim dados As XmlDocument = New XmlDocument
dados.LoadXml([Ô]<?xml version=[Ô][Ô]1.0[Ô][Ô] encoding=[Ô][Ô]UTF-8[Ô][Ô]?><consStatServ versao=[Ô][Ô]4.00[Ô][Ô] xmlns=[Ô][Ô]http://www.portalfiscal.inf.br/nfe[Ô][Ô]><tpAmb>2</tpAmb><cUF>[Ô] & UF_N(xStatus_N_UF) & [Ô]</cUF><xServ>STATUS</xServ></consStatServ>[Ô])
strRetorno = wsMsg.nfeStatusServicoNF(dados)
e sempre da erro na linha [ô] strRetorno = wsMsg.nfeStatusServicoNF(dados)
Diz que o SOAP esta Misturado ou Incompativel
Que tipo é o parâmetro do método nfeStatusServicoNF?
Citação::
Que tipo é o parâmetro do método nfeStatusServicoNF?
e uma Função que recebe o XML para serializar
[ô][ô][ô]<remarks/>
Public Event nfeStatusServicoNFCompleted As nfeStatusServicoNFCompletedEventHandler
[ô][ô][ô]<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute([Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF[Ô], Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
Public Function nfeStatusServicoNF(<System.Xml.Serialization.XmlElementAttribute([Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> ByVal nfeDadosMsg As System.Xml.XmlNode) As <System.Xml.Serialization.XmlElementAttribute([Ô]nfeResultMsg[Ô], [Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> System.Xml.XmlNode
Dim results() As Object = Me.Invoke([Ô]nfeStatusServicoNF[Ô], New Object() {nfeDadosMsg})
Return CType(results(0), System.Xml.XmlNode)
End Function
Eu peguei essa Classe na Uninfe e alterei para VB
funcionou Perfeitamente
o problema agora são as demais Classes pois so achei essa na Uninfe
[ô]------------------------------------------------------------------------------
[ô] <auto-generated>
[ô] This code was generated by a tool.
[ô] Runtime Version:4.0.30319.1
[ô]
[ô] Changes to this file may cause incorrect behavior and will be lost if
[ô] the code is regenerated.
[ô] </auto-generated>
[ô]------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization
[ô]
[ô]This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.1.
[ô]
Namespace StatusNFe4
[ô][ô][ô]<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.Web.Services[Ô], [Ô]4.0.30319.1[Ô]), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute([Ô]code[Ô]), _
System.Web.Services.WebServiceBindingAttribute(Name:=[Ô]NFeStatusServico4ServiceBinding[Ô], [Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> _
Partial Public Class NFeStatusServico4
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
Private nfeStatusServicoNFOperationCompleted As System.Threading.SendOrPostCallback
Private useDefaultCredentialsSetExplicitly As Boolean
[ô][ô][ô]<remarks/>
Public Sub New(ByVal v_RUL As String)
MyBase.New()
Me.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap12
Me.Url = v_RUL [ô]Global.WindowsApplication1.My.MySettings.Default.WindowsApplication5_StatusGO_NFeStatusServico4
If (Me.IsLocalFileSystemWebService(Me.Url) = True) Then
Me.UseDefaultCredentials = True
Me.useDefaultCredentialsSetExplicitly = False
Else
Me.useDefaultCredentialsSetExplicitly = True
End If
End Sub
Public Shadows Property Url() As String
Get
Return MyBase.Url
End Get
Set(ByVal value As String)
If (((Me.IsLocalFileSystemWebService(MyBase.Url) = True) _
AndAlso (Me.useDefaultCredentialsSetExplicitly = False)) _
AndAlso (Me.IsLocalFileSystemWebService(value) = False)) Then
MyBase.UseDefaultCredentials = False
End If
MyBase.Url = value
End Set
End Property
Public Shadows Property UseDefaultCredentials() As Boolean
Get
Return MyBase.UseDefaultCredentials
End Get
Set(ByVal value As Boolean)
MyBase.UseDefaultCredentials = value
Me.useDefaultCredentialsSetExplicitly = True
End Set
End Property
[ô][ô][ô]<remarks/>
Public Event nfeStatusServicoNFCompleted As nfeStatusServicoNFCompletedEventHandler
[ô][ô][ô]<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute([Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4/nfeStatusServicoNF[Ô], Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
Public Function nfeStatusServicoNF(<System.Xml.Serialization.XmlElementAttribute([Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> ByVal nfeDadosMsg As System.Xml.XmlNode) As <System.Xml.Serialization.XmlElementAttribute([Ô]nfeResultMsg[Ô], [Namespace]:=[Ô]http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4[Ô])> System.Xml.XmlNode
Dim results() As Object = Me.Invoke([Ô]nfeStatusServicoNF[Ô], New Object() {nfeDadosMsg})
Return CType(results(0), System.Xml.XmlNode)
End Function
[ô][ô][ô]<remarks/>
Public Overloads Sub nfeStatusServicoNFAsync(ByVal nfeDadosMsg As System.Xml.XmlNode)
Me.nfeStatusServicoNFAsync(nfeDadosMsg, Nothing)
End Sub
[ô][ô][ô]<remarks/>
Public Overloads Sub nfeStatusServicoNFAsync(ByVal nfeDadosMsg As System.Xml.XmlNode, ByVal userState As Object)
If (Me.nfeStatusServicoNFOperationCompleted Is Nothing) Then
Me.nfeStatusServicoNFOperationCompleted = AddressOf Me.OnnfeStatusServicoNFOperationCompleted
End If
Me.InvokeAsync([Ô]nfeStatusServicoNF[Ô], New Object() {nfeDadosMsg}, Me.nfeStatusServicoNFOperationCompleted, userState)
End Sub
Private Sub OnnfeStatusServicoNFOperationCompleted(ByVal arg As Object)
If (Not (Me.nfeStatusServicoNFCompletedEvent) Is Nothing) Then
Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg, System.Web.Services.Protocols.InvokeCompletedEventArgs)
RaiseEvent nfeStatusServicoNFCompleted(Me, New nfeStatusServicoNFCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState))
End If
End Sub
[ô][ô][ô]<remarks/>
Public Shadows Sub CancelAsync(ByVal userState As Object)
MyBase.CancelAsync(userState)
End Sub
Private Function IsLocalFileSystemWebService(ByVal url As String) As Boolean
If ((url Is Nothing) _
OrElse (url Is String.Empty)) Then
Return False
End If
Dim wsUri As System.Uri = New System.Uri(url)
If ((wsUri.Port >= 1024) _
AndAlso (String.Compare(wsUri.Host, [Ô]localHost[Ô], System.StringComparison.OrdinalIgnoreCase) = 0)) Then
Return True
End If
Return False
End Function
End Class
[ô][ô][ô]<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.Web.Services[Ô], [Ô]4.0.30319.1[Ô])> _
Public Delegate Sub nfeStatusServicoNFCompletedEventHandler(ByVal sender As Object, ByVal e As nfeStatusServicoNFCompletedEventArgs)
[ô][ô][ô]<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.Web.Services[Ô], [Ô]4.0.30319.1[Ô]), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute([Ô]code[Ô])> _
Partial Public Class nfeStatusServicoNFCompletedEventArgs
Inherits System.ComponentModel.AsyncCompletedEventArgs
Private results() As Object
Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object)
MyBase.New(exception, cancelled, userState)
Me.results = results
End Sub
[ô][ô][ô]<remarks/>
Public ReadOnly Property Result() As System.Xml.XmlNode
Get
Me.RaiseExceptionIfNecessary()
Return CType(Me.results(0), System.Xml.XmlNode)
End Get
End Property
End Class
End Namespace
funcionou Perfeitamente
o problema agora são as demais Classes pois so achei essa na Uninfe
Tópico encerrado , respostas não são mais permitidas