No se porque me da el error 503. Estoy progrmamando en vb.net, no se si alguien me puede ayudar a ver donde está el error, lo he pasado a c el código.
Código:
public void envio(System.Xml.XmlDocument xml, System.Security.Cryptography.X509Certificates.X509Certificate2 certificado)
{
byte[] sentXml = System.Text.Encoding.UTF8.GetBytes(xml.OuterXml);
Stream stream;
request.Method = "POST";
request.ContentType = "application/xml; charset=utf-8";
request.ContentType = "text/xml; charset=utf-8";
request.Timeout = 3000000;
request.ClientCertificates.Add(certificado);
// soap action (this is the header I tried to add. Didn't work.)
request.Headers.Add("SOAPAction", "h t t p s://tbai-prep.egoitza.gipuzkoa.eus/WAS/HACI/HTBRecepcionFacturasWEB/rest/recepcionFacturas/alta");
// Set the ContentLength property of the WebRequest.
request.ContentLength = sentXml.Length;
stream = request.GetRequestStream();
try
{
stream.Write(sentXml, 0, sentXml.Length);
}
catch (Exception ex)
{
Interaction.MsgBox("Error Sending Data: " + ex.Message);
}
// Close the Stream object.
stream.Close();
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine("Received response with status {0} {1}.", response.StatusCode, response.StatusDescription);
if (response.StatusCode == HttpStatusCode.OK)
{
XmlDocument responseXML = new XmlDocument();
Stream a = response.GetResponseStream;
StreamReader reader = new StreamReader(a);
Interaction.MsgBox(reader.ReadToEnd());
responseXML.Load(response.GetResponseStream());
responseXML.Save("respuesta.xml");
responseXML.Save(Console.Out);
}
response.Close();
}
catch (Exception ex)
{
Interaction.MsgBox("Error Getting Response: " + ex.Message);
}
}