0
I am getting the following error while trying to consume Nfe GO Webservice
Error 90 - Nfestatusservico. The remote server returned an unexpected response: (495) Unknown Code
as I am creating a dll I don’t have the configuration file
private System.ServiceModel.Channels.CustomBinding getBinding
{
get
{
System.ServiceModel.Channels.HttpsTransportBindingElement objHttpsTransportBindingElement = new HttpsTransportBindingElement();
objHttpsTransportBindingElement.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
objHttpsTransportBindingElement.ManualAddressing = false;
objHttpsTransportBindingElement.MaxBufferPoolSize = 524288;
objHttpsTransportBindingElement.MaxReceivedMessageSize = 65536;
objHttpsTransportBindingElement.AllowCookies = false;
objHttpsTransportBindingElement.BypassProxyOnLocal = false;
objHttpsTransportBindingElement.KeepAliveEnabled = true;
objHttpsTransportBindingElement.MaxBufferSize = 65536;
objHttpsTransportBindingElement.Realm = string.Empty;
objHttpsTransportBindingElement.TransferMode = TransferMode.Buffered;
objHttpsTransportBindingElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Digest;
objHttpsTransportBindingElement.UnsafeConnectionNtlmAuthentication = false;
objHttpsTransportBindingElement.UseDefaultWebProxy = true;
objHttpsTransportBindingElement.RequireClientCertificate = true;
TextMessageEncodingBindingElement objTextMessageEncodingBindingElement = new TextMessageEncodingBindingElement();
objTextMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12;
objTextMessageEncodingBindingElement.WriteEncoding = Encoding.UTF8;
objTextMessageEncodingBindingElement.MaxReadPoolSize = 64;
objTextMessageEncodingBindingElement.MaxWritePoolSize = 16;
System.ServiceModel.Channels.CustomBinding objCustomBinding = new System.ServiceModel.Channels.CustomBinding(objTextMessageEncodingBindingElement, objHttpsTransportBindingElement);
return objCustomBinding;
}
}
public void NfeStatusServico(string cUF, string tpAmb, string noSerieCert, string hostWS, string pUF, bool trace)
{
Certificado cert = new Certificado();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(hostWS);
NFeStatusServico4.NFeStatusServico4ServiceClient cliente = new NFeStatusServico4.NFeStatusServico4ServiceClient(getBindingGO, address);
cliente.Endpoint.Address = address;
cliente.ClientCredentials.ServiceCertificate.DefaultCertificate = cert.BuscaNroSerie(noSerieCert, false);
cliente.ClientCredentials.ClientCertificate.Certificate = cert.BuscaNroSerie(noSerieCert, false);
string corpoMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<consStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"" + Le_Config("NFE", "verProc").ToString() + "\">" +
"<tpAmb>" + tpAmb + "</tpAmb>" +
"<cUF>" + cUF + "</cUF>" +
"<xServ>STATUS</xServ>" +
"</consStatServ>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(corpoMsg);
if (trace)
MessageBox.Show(xmlDoc.DocumentElement.InnerXml, "Envio de Msg - NfeStatusServico4");
XmlNode retNode = cliente.nfeStatusServicoNF(xmlDoc.DocumentElement);
}
This method is working for other states only not for CE and GO
what I have to do to make it work for CE and GO
Thank you
Please somebody help me
– Paulo
I was able to solve it by adjusting it to the project property -> Application -> Target Structure = . Net Framework 4.5
– Paulo
and also add and change Servicepointmanager.Securityprotocol = Securityprotocoltype.Tls; to System.Net.Servicepointmanager.Securityprotocol = Securityprotocoltype.Tls12; worked for all states
– Paulo