2
In my project, I need to communicate with a Webservice and send data to it. However when I do the envelopment and sent, it shows the following error:
"Could not create SSL/TLS Secure Channel.".
Follows code:
Call of the Metodo:
string xml = @"<tjce:solicitacaoSelo xmlns:ds=""http://www.w3.org/2000/09/xmldsig#"" xmlns:tjce=""http://www.tjce.jus.br/selodigital/schemas"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.tjce.jus.br/selodigital/schemas xsSolicitacaoSelo_v1.0.xsd "">" +
@"<cabecalho> <versao>1.11</versao> <dataHora>20160913T03:54:09</dataHora> <ambiente>2</ambiente> <serventia> <codigoServentia>000307</codigoServentia> </serventia> </cabecalho> <solicitante> <nomePessoa>CICERO MOZART MACHADO</nomePessoa> <documento> <tipoDocumento>1</tipoDocumento> <numero>90002167595</numero> <descricao>IDENTIDADE</descricao> <orgaoEmissor>SSP-CE</orgaoEmissor> <dataEmissao>1998-03-27</dataEmissao> </documento> <telefone> <tipoTelefone>1</tipoTelefone> <ddd>85</ddd> <numero>32269240</numero> </telefone> <email> <tipoEmail>1</tipoEmail>" +
@"<enderecoEmail>[email protected]</enderecoEmail> </email> </solicitante> <idSolicitacaoSelo>20</idSolicitacaoSelo> <itens> <itemSolicitacao> <sequencial>1</sequencial> <codigoSelo> <codigo>1</codigo> </codigoSelo> <quantidade>1</quantidade> </itemSolicitacao> </itens></tjce:solicitacaoSelo>";
CSoap.ExecutaWebService("https://selodigital.tjce.jus.br/wsselodigital-homologacao/SolicitacaoSelo?wsdl", xml);
Solicitacao.solicitaSelos ws = new Solicitacao.solicitaSelos();
public class CSoap
{
public static void ExecutaWebService(string _url, string xml)
{
HttpWebRequest request = CreateWebRequest(_url);
XmlDocument soapEnvelopeXml = CreateSoapEnvelope(xml);
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string soapResult = rd.ReadToEnd();
Console.WriteLine(soapResult);
}
}
}
private static HttpWebRequest CreateWebRequest(string url)
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Headers.Add("SOAPAction:");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
}
private static XmlDocument CreateSoapEnvelope(string xml)
{
XmlDocument soapEnvelop = new XmlDocument();
soapEnvelop.LoadXml(@"<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/1999/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/1999/XMLSchema"">
<SOAP-ENV:Body>" + xml + @"</SOAP-ENV:Body></SOAP-ENV:Envelope>");
return soapEnvelop;
}
}
You are using digital certificate?
– JcSaint
Yes, and I’ve used up the Webservice methods, but I can’t access the XML upload. And from what I’ve been informing myself, it doesn’t require authentication, SSL or TLS.
– Germano Sampaio
Usually this error occurs because there are problems in xml. see if tjce has an xml validation service...
– JcSaint
I believe that is why, because XML is validated
– Germano Sampaio