[英]The remote server returned an error: (500) Internal Server Error Web service
I am trying to send a SOAP XML to oracle webservice. 我正在尝试将SOAP XML发送到oracle webservice。 Service reference does not work well so I decide to use webrequest but I am getting an errror "The remote server returned an error: (500) Internal Server Error. " 服务参考无法正常运行,因此我决定使用webrequest,但出现错误“远程服务器返回错误:(500)内部服务器错误。”
string envelope = System.IO.File.ReadAllText("test.xml");
byte[] byteArray = Encoding.UTF8.GetBytes(envelope);
byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes("xxxxx" + ":" + "xxxxx");
string credentials = System.Convert.ToBase64String(toEncodeAsBytes);
HttpWebRequest request =(HttpWebRequest)WebRequest.Create("https://ehpq-test.fa.em2.oraclecloud.com/fscmService/SupplierServiceV2");
request.Method = "POST";
request.ContentType = "text/xml;charset=UTF-8";
request.ContentLength = byteArray.Length;
request.Headers.Add("Authorization", "Basic " + credentials);
request.Headers.Add("SOAPAction", "https://ehpq-test.fa.em2.oraclecloud.com/fscmService/SupplierServiceV2");
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
var doc = XDocument.Load(stream);
}
}
It can be very difficult to diagnose the problem that has occurred in the server from your client code. 从客户端代码中诊断服务器中发生的问题可能非常困难。 If you have access to the server, you can view the error logs for the web server. 如果您有权访问服务器,则可以查看Web服务器的错误日志。
For instance, with Nginx on Ubuntu you would want to navigate to /var/log/nginx
directory and then either use nano
or tail -f
to view the full contents of the file error.log
or similarly named. 例如,在Ubuntu上使用Nginx时,您需要导航到/var/log/nginx
目录,然后使用nano
或tail -f
查看error.log
或类似名称的文件的完整内容。 This would be the place that lists the exact cause of the server to throw a 500. It may not be the case that your request is malformed, but that the endpoint is misconfigured server-side. 这将是列出服务器抛出500的确切原因的地方。您的请求可能格式不正确,但端点在服务器端配置不正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.