我正在尝试将xml数据发送到Web服务器,但是当我发送数据时出现错误,System.Net.WebException:'远程服务器返回错误:(500)内部服务器错误。“,
这是我的代码:
public string postXMLData(string soap_action, string requestXml)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://secure.yieldplanet.com/XmlServices/ChannelManager.asmx");
request.Headers.Add(@"SOAPAction:XmlServices/" + soap_action);
request.ContentType = "text/xml; encoding='utf-8'";
request.Accept = "text/xml";
request.Method = "POST";
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes(requestXml);
request.ContentLength = bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
HttpWebResponse response;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
string responseStr = new StreamReader(responseStream).ReadToEnd();
return responseStr;
}
return null;
}