0
I have the following Code:
try
{
public string ProcessAttachment(string fileInput)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://flnws001qae.nexxera.com:80/nexxeraws/v2/SkylineWSv2");
req.Method = "POST";
req.ProtocolVersion = HttpVersion.Version11;
req.Headers.Add("Accept-Encoding", "gzip,deflate");
req.ContentType = "multipart/related; type=\"text/xml\"; start=\"teste\"; boundary=\"----=_Part_72_348989292.1565031692584\"";
req.Headers.Add("SOAPAction", "\"\"");
req.Headers.Add("MIME-Version", "1.0");
//req.ContentLength = 1854;
req.Host = "flnws001qae.nexxera.com:80";
req.UserAgent = "Apache-HttpClient/4.1.1 (java 1.5)";
req.KeepAlive = true;
System.Net.ServicePointManager.Expect100Continue = false;
Stream memStream = new System.IO.MemoryStream();
FileStream fileStream = new FileStream(fileInput, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
{
memStream.Write(buffer, 0, bytesRead);
}
fileStream.Close();
Stream stm = req.GetRequestStream();
memStream.Position = 0;
byte[] tempBuffer = new byte[memStream.Length];
memStream.Read(tempBuffer, 0, tempBuffer.Length);
memStream.Close();
stm.Write(tempBuffer, 0, tempBuffer.Length);
stm.Close();
HttpWebResponse resp = null;
resp = (HttpWebResponse)req.GetResponse();
stm = resp.GetResponseStream();
StreamReader r = new StreamReader(stm);
return r.ReadToEnd();
}
}
catch (WebException ex)
{
string exMessage = ex.Message;
throw ex;
}
}
I have the following return:
Remote server returned an error: (500) Internal Server Error.
There is a way to get back Webservice, for example " Authentication failure!" In the soapui I have the return:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode xmlns:codeNS="http://schemas.xmlsoap.org/soap/envelope/">codeNS:Server</faultcode>
<faultstring>1090 - Falha de autenticação!</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>