ERRO AO TENTAR CONSUMIR WEBSERVICE NFS-E
Olá pessoal,
Ao tentar enviar um arquivo xml, via WebService, para prefeitura de Belo Horizonte está ocorrendo o seguinte erro:
Não foi possÃvel estabelecer uma relação de confiança para o canal protegido SSL/TLS com a autoridade [ô]bhisshomologa.pbh.gov.br[ô].â€
Alguem sabe como resolver?
Desde já obrigado pela atenção!
Ao tentar enviar um arquivo xml, via WebService, para prefeitura de Belo Horizonte está ocorrendo o seguinte erro:
Não foi possÃvel estabelecer uma relação de confiança para o canal protegido SSL/TLS com a autoridade [ô]bhisshomologa.pbh.gov.br[ô].â€
Alguem sabe como resolver?
Desde já obrigado pela atenção!
Achei algumas solucoes aqui:
http://social.msdn.microsoft.com/Forums/pt-BR/webservicespt/thread/4aab57c3-5aed-495d-a21f-f33e652cf546
http://br.groups.yahoo.com/group/uninfe/message/2801
http://social.msdn.microsoft.com/Forums/eu/wcf/thread/92fc5d59-892f-4671-b0c8-85877b0ed166
vlw
http://social.msdn.microsoft.com/Forums/pt-BR/webservicespt/thread/4aab57c3-5aed-495d-a21f-f33e652cf546
http://br.groups.yahoo.com/group/uninfe/message/2801
http://social.msdn.microsoft.com/Forums/eu/wcf/thread/92fc5d59-892f-4671-b0c8-85877b0ed166
vlw
é o seguinte,
Estou utilizando o Visual Studio 2010 para desenvolver uma ferramenta para enivar Nfs-e para prefeitura via WebService. Utilizei a opção [Ô]Add Service Reference[Ô] do Visual Studio para pegar as classes do Ws (https://bhisshomologa.pbh.gov.br/bhiss-ws/nfse?wsdl). Ao tentar consumir o webService com a classe criada esta dando o erro: [Ô]Não foi possÃvel estabelecer uma relação de confiança para o canal protegido SSL/TLS com a autoridade [ô]bhisshomologa.pbh.gov.br[ô]
Acredito que o erro é porque eu não consegui adicionar o certificado digital do cliente na chamada do WebService. Alguem sabe como fazer isso? Um das classes criadas pelo VS tem em seu construtor um tal de endpointConfigurationName, será que isso?
Segue parte da classes criadas pelo VS
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.ServiceModel[Ô], [Ô]4.0.0.0[Ô])> _
Partial Public Class nfseClient
Inherits System.ServiceModel.ClientBase(Of WsHomPbh.nfse)
[ô]Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
Implements WsHomPbh.nfse
Public Sub New()
MyBase.New
End Sub
Public Sub New(ByVal endpointConfigurationName As String)
MyBase.New(endpointConfigurationName)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(binding, remoteAddress)
End Sub
Public Function CancelarNfse(ByVal request As WsHomPbh.CancelarNfseRequest) As WsHomPbh.CancelarNfseResponse Implements WsHomPbh.nfse.CancelarNfse
Return MyBase.Channel.CancelarNfse(request)
End Function
Public Function ConsultarLoteRps(ByVal request As WsHomPbh.ConsultarLoteRpsRequest) As WsHomPbh.ConsultarLoteRpsResponse Implements WsHomPbh.nfse.ConsultarLoteRps
Return MyBase.Channel.ConsultarLoteRps(request)
End Function
Public Function ConsultarNfse(ByVal request As WsHomPbh.ConsultarNfseRequest) As WsHomPbh.ConsultarNfseResponse Implements WsHomPbh.nfse.ConsultarNfse
Return MyBase.Channel.ConsultarNfse(request)
End Function
Public Function ConsultarNfsePorFaixa(ByVal request As WsHomPbh.ConsultarNfsePorFaixaRequest) As WsHomPbh.ConsultarNfsePorFaixaResponse Implements WsHomPbh.nfse.ConsultarNfsePorFaixa
Return MyBase.Channel.ConsultarNfsePorFaixa(request)
End Function
Public Function ConsultarNfsePorRps(ByVal request As WsHomPbh.ConsultarNfsePorRpsRequest) As WsHomPbh.ConsultarNfsePorRpsResponse Implements WsHomPbh.nfse.ConsultarNfsePorRps
Return MyBase.Channel.ConsultarNfsePorRps(request)
End Function
Public Function ConsultarSituacaoLoteRps(ByVal request As WsHomPbh.ConsultarSituacaoLoteRpsRequest) As WsHomPbh.ConsultarSituacaoLoteRpsResponse Implements WsHomPbh.nfse.ConsultarSituacaoLoteRps
Return MyBase.Channel.ConsultarSituacaoLoteRps(request)
End Function
Public Function RecepcionarLoteRps(ByVal request As WsHomPbh.RecepcionarLoteRpsRequest) As WsHomPbh.RecepcionarLoteRpsResponse Implements WsHomPbh.nfse.RecepcionarLoteRps
Return MyBase.Channel.RecepcionarLoteRps(request)
End Function
Public Function GerarNfse(ByVal request As WsHomPbh.GerarNfseRequest) As WsHomPbh.GerarNfseResponse Implements WsHomPbh.nfse.GerarNfse
Return MyBase.Channel.GerarNfse(request)
End Function
[ô]Protected Overrides Function GetWebRequest(ByVal uri As Uri) As Net.WebRequest
[ô]End Function
End Class
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.ServiceModel[Ô], [Ô]4.0.0.0[Ô]), _
System.ServiceModel.ServiceContractAttribute([Namespace]:=[Ô]http://ws.bhiss.pbh.gov.br[Ô], ConfigurationName:=[Ô]WsHomPbh.nfse[Ô])> _
Public Interface nfse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/CancelarNfse[Ô], ReplyAction:=[Ô]*[Ô])> _
Function CancelarNfse(ByVal request As WsHomPbh.CancelarNfseRequest) As WsHomPbh.CancelarNfseResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarLoteRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarLoteRps(ByVal request As WsHomPbh.ConsultarLoteRpsRequest) As WsHomPbh.ConsultarLoteRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarNfse[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarNfse(ByVal request As WsHomPbh.ConsultarNfseRequest) As WsHomPbh.ConsultarNfseResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarNfsePorFaixa[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarNfsePorFaixa(ByVal request As WsHomPbh.ConsultarNfsePorFaixaRequest) As WsHomPbh.ConsultarNfsePorFaixaResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarNfsePorRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarNfsePorRps(ByVal request As WsHomPbh.ConsultarNfsePorRpsRequest) As WsHomPbh.ConsultarNfsePorRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarSituacaoLoteRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarSituacaoLoteRps(ByVal request As WsHomPbh.ConsultarSituacaoLoteRpsRequest) As WsHomPbh.ConsultarSituacaoLoteRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/RecepcionarLoteRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function RecepcionarLoteRps(ByVal request As WsHomPbh.RecepcionarLoteRpsRequest) As WsHomPbh.RecepcionarLoteRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/GerarNfse[Ô], ReplyAction:=[Ô]*[Ô])> _
Function GerarNfse(ByVal request As WsHomPbh.GerarNfseRequest) As WsHomPbh.GerarNfseResponse
End Interface
Estou utilizando o Visual Studio 2010 para desenvolver uma ferramenta para enivar Nfs-e para prefeitura via WebService. Utilizei a opção [Ô]Add Service Reference[Ô] do Visual Studio para pegar as classes do Ws (https://bhisshomologa.pbh.gov.br/bhiss-ws/nfse?wsdl). Ao tentar consumir o webService com a classe criada esta dando o erro: [Ô]Não foi possÃvel estabelecer uma relação de confiança para o canal protegido SSL/TLS com a autoridade [ô]bhisshomologa.pbh.gov.br[ô]
Acredito que o erro é porque eu não consegui adicionar o certificado digital do cliente na chamada do WebService. Alguem sabe como fazer isso? Um das classes criadas pelo VS tem em seu construtor um tal de endpointConfigurationName, será que isso?
Segue parte da classes criadas pelo VS
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.ServiceModel[Ô], [Ô]4.0.0.0[Ô])> _
Partial Public Class nfseClient
Inherits System.ServiceModel.ClientBase(Of WsHomPbh.nfse)
[ô]Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
Implements WsHomPbh.nfse
Public Sub New()
MyBase.New
End Sub
Public Sub New(ByVal endpointConfigurationName As String)
MyBase.New(endpointConfigurationName)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(binding, remoteAddress)
End Sub
Public Function CancelarNfse(ByVal request As WsHomPbh.CancelarNfseRequest) As WsHomPbh.CancelarNfseResponse Implements WsHomPbh.nfse.CancelarNfse
Return MyBase.Channel.CancelarNfse(request)
End Function
Public Function ConsultarLoteRps(ByVal request As WsHomPbh.ConsultarLoteRpsRequest) As WsHomPbh.ConsultarLoteRpsResponse Implements WsHomPbh.nfse.ConsultarLoteRps
Return MyBase.Channel.ConsultarLoteRps(request)
End Function
Public Function ConsultarNfse(ByVal request As WsHomPbh.ConsultarNfseRequest) As WsHomPbh.ConsultarNfseResponse Implements WsHomPbh.nfse.ConsultarNfse
Return MyBase.Channel.ConsultarNfse(request)
End Function
Public Function ConsultarNfsePorFaixa(ByVal request As WsHomPbh.ConsultarNfsePorFaixaRequest) As WsHomPbh.ConsultarNfsePorFaixaResponse Implements WsHomPbh.nfse.ConsultarNfsePorFaixa
Return MyBase.Channel.ConsultarNfsePorFaixa(request)
End Function
Public Function ConsultarNfsePorRps(ByVal request As WsHomPbh.ConsultarNfsePorRpsRequest) As WsHomPbh.ConsultarNfsePorRpsResponse Implements WsHomPbh.nfse.ConsultarNfsePorRps
Return MyBase.Channel.ConsultarNfsePorRps(request)
End Function
Public Function ConsultarSituacaoLoteRps(ByVal request As WsHomPbh.ConsultarSituacaoLoteRpsRequest) As WsHomPbh.ConsultarSituacaoLoteRpsResponse Implements WsHomPbh.nfse.ConsultarSituacaoLoteRps
Return MyBase.Channel.ConsultarSituacaoLoteRps(request)
End Function
Public Function RecepcionarLoteRps(ByVal request As WsHomPbh.RecepcionarLoteRpsRequest) As WsHomPbh.RecepcionarLoteRpsResponse Implements WsHomPbh.nfse.RecepcionarLoteRps
Return MyBase.Channel.RecepcionarLoteRps(request)
End Function
Public Function GerarNfse(ByVal request As WsHomPbh.GerarNfseRequest) As WsHomPbh.GerarNfseResponse Implements WsHomPbh.nfse.GerarNfse
Return MyBase.Channel.GerarNfse(request)
End Function
[ô]Protected Overrides Function GetWebRequest(ByVal uri As Uri) As Net.WebRequest
[ô]End Function
End Class
<System.CodeDom.Compiler.GeneratedCodeAttribute([Ô]System.ServiceModel[Ô], [Ô]4.0.0.0[Ô]), _
System.ServiceModel.ServiceContractAttribute([Namespace]:=[Ô]http://ws.bhiss.pbh.gov.br[Ô], ConfigurationName:=[Ô]WsHomPbh.nfse[Ô])> _
Public Interface nfse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/CancelarNfse[Ô], ReplyAction:=[Ô]*[Ô])> _
Function CancelarNfse(ByVal request As WsHomPbh.CancelarNfseRequest) As WsHomPbh.CancelarNfseResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarLoteRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarLoteRps(ByVal request As WsHomPbh.ConsultarLoteRpsRequest) As WsHomPbh.ConsultarLoteRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarNfse[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarNfse(ByVal request As WsHomPbh.ConsultarNfseRequest) As WsHomPbh.ConsultarNfseResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarNfsePorFaixa[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarNfsePorFaixa(ByVal request As WsHomPbh.ConsultarNfsePorFaixaRequest) As WsHomPbh.ConsultarNfsePorFaixaResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarNfsePorRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarNfsePorRps(ByVal request As WsHomPbh.ConsultarNfsePorRpsRequest) As WsHomPbh.ConsultarNfsePorRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/ConsultarSituacaoLoteRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function ConsultarSituacaoLoteRps(ByVal request As WsHomPbh.ConsultarSituacaoLoteRpsRequest) As WsHomPbh.ConsultarSituacaoLoteRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/RecepcionarLoteRps[Ô], ReplyAction:=[Ô]*[Ô])> _
Function RecepcionarLoteRps(ByVal request As WsHomPbh.RecepcionarLoteRpsRequest) As WsHomPbh.RecepcionarLoteRpsResponse
<System.ServiceModel.OperationContractAttribute(Action:=[Ô]http://ws.bhiss.pbh.gov.br/GerarNfse[Ô], ReplyAction:=[Ô]*[Ô])> _
Function GerarNfse(ByVal request As WsHomPbh.GerarNfseRequest) As WsHomPbh.GerarNfseResponse
End Interface
Você deu uma olhada nos posts que coloquei pra você?
vlw
vlw
Jaba,
Olhei sim. Alias eu já havia até pesquisado esses mesmo links antes. Me ajudou em partes, porém, não resolveu o problema.
Olhei sim. Alias eu já havia até pesquisado esses mesmo links antes. Me ajudou em partes, porém, não resolveu o problema.
Pessoa,
Minhas classes estavam erradas. Utilizei a opção Add Web Reference do Visual Studio para criar as classes corretas.
Agora o problema é o seguinte: Ao chamar algum método da classe ocorre o erro: A solicitação foi anulada: Não foi possÃvel criar um canal seguro para SSL/TLS. (erro parecido, mas não igual ao erro anterior).
O interessante e que quando faço uma nova solicitação imediatamente após o erro eu consigo fazer a comunicação.
A classe criada pelo Visual Studio implemente a Classe SoapHttpClientProtocol.
Algum já possou isso?
Minhas classes estavam erradas. Utilizei a opção Add Web Reference do Visual Studio para criar as classes corretas.
Agora o problema é o seguinte: Ao chamar algum método da classe ocorre o erro: A solicitação foi anulada: Não foi possÃvel criar um canal seguro para SSL/TLS. (erro parecido, mas não igual ao erro anterior).
O interessante e que quando faço uma nova solicitação imediatamente após o erro eu consigo fazer a comunicação.
A classe criada pelo Visual Studio implemente a Classe SoapHttpClientProtocol.
Algum já possou isso?
O webservice está em um servidor com https?
Se sim, está passando as credenciais?
Se sim, está passando as credenciais?
KERPLUNK,
O Servidor é: https://bhisshomologa.pbh.gov.br/bhiss-ws/nfse?wsdl
Na instância da classe eu passo o certificado dessa forma: ws.ClientCertificates(CertificadoDoCliente).
Percebi que existe a propriedade Credentials conforme você mencionou.
Neste casso como eu faço para passar essa Credentials???
Abaixo parte da classe (está em c#):
public partial class NfseWSService : System.Web.Services.Protocols.SoapHttpClientProtocol {
private System.Threading.SendOrPostCallback CancelarNfseOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarLoteRpsOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarNfseOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarNfsePorFaixaOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarNfsePorRpsOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarSituacaoLoteRpsOperationCompleted;
private System.Threading.SendOrPostCallback RecepcionarLoteRpsOperationCompleted;
private System.Threading.SendOrPostCallback GerarNfseOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>
public NfseWSService() {
this.Url = global::WsNfse.Properties.Settings.Default.WsNfse_WsPbhHomologacao_NfseWSService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
/// <remarks/>
public event CancelarNfseCompletedEventHandler CancelarNfseCompleted;
/// <remarks/>
public event ConsultarLoteRpsCompletedEventHandler ConsultarLoteRpsCompleted;
/// <remarks/>
public event ConsultarNfseCompletedEventHandler ConsultarNfseCompleted;
/// <remarks/>
public event ConsultarNfsePorFaixaCompletedEventHandler ConsultarNfsePorFaixaCompleted;
/// <remarks/>
public event ConsultarNfsePorRpsCompletedEventHandler ConsultarNfsePorRpsCompleted;
/// <remarks/>
public event ConsultarSituacaoLoteRpsCompletedEventHandler ConsultarSituacaoLoteRpsCompleted;
/// <remarks/>
public event RecepcionarLoteRpsCompletedEventHandler RecepcionarLoteRpsCompleted;
/// <remarks/>
public event GerarNfseCompletedEventHandler GerarNfseCompleted;
..........
/// <remarks/>
public void RecepcionarLoteRpsAsync(string nfseCabecMsg, string nfseDadosMsg) {
this.RecepcionarLoteRpsAsync(nfseCabecMsg, nfseDadosMsg, null);
}
/// <remarks/>
public void RecepcionarLoteRpsAsync(string nfseCabecMsg, string nfseDadosMsg, object userState) {
if ((this.RecepcionarLoteRpsOperationCompleted == null)) {
this.RecepcionarLoteRpsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRecepcionarLoteRpsOperationCompleted);
}
this.InvokeAsync([Ô]RecepcionarLoteRps[Ô], new object[] {
nfseCabecMsg,
nfseDadosMsg}, this.RecepcionarLoteRpsOperationCompleted, userState);
}
private void OnRecepcionarLoteRpsOperationCompleted(object arg) {
if ((this.RecepcionarLoteRpsCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.RecepcionarLoteRpsCompleted(this, new RecepcionarLoteRpsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
..........
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, [Ô]localHost[Ô], System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
O Servidor é: https://bhisshomologa.pbh.gov.br/bhiss-ws/nfse?wsdl
Na instância da classe eu passo o certificado dessa forma: ws.ClientCertificates(CertificadoDoCliente).
Percebi que existe a propriedade Credentials conforme você mencionou.
Neste casso como eu faço para passar essa Credentials???
Abaixo parte da classe (está em c#):
public partial class NfseWSService : System.Web.Services.Protocols.SoapHttpClientProtocol {
private System.Threading.SendOrPostCallback CancelarNfseOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarLoteRpsOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarNfseOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarNfsePorFaixaOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarNfsePorRpsOperationCompleted;
private System.Threading.SendOrPostCallback ConsultarSituacaoLoteRpsOperationCompleted;
private System.Threading.SendOrPostCallback RecepcionarLoteRpsOperationCompleted;
private System.Threading.SendOrPostCallback GerarNfseOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>
public NfseWSService() {
this.Url = global::WsNfse.Properties.Settings.Default.WsNfse_WsPbhHomologacao_NfseWSService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
/// <remarks/>
public event CancelarNfseCompletedEventHandler CancelarNfseCompleted;
/// <remarks/>
public event ConsultarLoteRpsCompletedEventHandler ConsultarLoteRpsCompleted;
/// <remarks/>
public event ConsultarNfseCompletedEventHandler ConsultarNfseCompleted;
/// <remarks/>
public event ConsultarNfsePorFaixaCompletedEventHandler ConsultarNfsePorFaixaCompleted;
/// <remarks/>
public event ConsultarNfsePorRpsCompletedEventHandler ConsultarNfsePorRpsCompleted;
/// <remarks/>
public event ConsultarSituacaoLoteRpsCompletedEventHandler ConsultarSituacaoLoteRpsCompleted;
/// <remarks/>
public event RecepcionarLoteRpsCompletedEventHandler RecepcionarLoteRpsCompleted;
/// <remarks/>
public event GerarNfseCompletedEventHandler GerarNfseCompleted;
..........
/// <remarks/>
public void RecepcionarLoteRpsAsync(string nfseCabecMsg, string nfseDadosMsg) {
this.RecepcionarLoteRpsAsync(nfseCabecMsg, nfseDadosMsg, null);
}
/// <remarks/>
public void RecepcionarLoteRpsAsync(string nfseCabecMsg, string nfseDadosMsg, object userState) {
if ((this.RecepcionarLoteRpsOperationCompleted == null)) {
this.RecepcionarLoteRpsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRecepcionarLoteRpsOperationCompleted);
}
this.InvokeAsync([Ô]RecepcionarLoteRps[Ô], new object[] {
nfseCabecMsg,
nfseDadosMsg}, this.RecepcionarLoteRpsOperationCompleted, userState);
}
private void OnRecepcionarLoteRpsOperationCompleted(object arg) {
if ((this.RecepcionarLoteRpsCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.RecepcionarLoteRpsCompleted(this, new RecepcionarLoteRpsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
..........
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, [Ô]localHost[Ô], System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
Tópico encerrado , respostas não são mais permitidas