我正在执行以下代码
string requestUrl = "http://SFPRTH010001:18109/1010-SF-TNTIN/Configurator/rest/importConfiguration?";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "text/html;charset=utf-8";
//request.ContentType = "application/json";
byte[] fileToSend = File.ReadAllBytes("TestSCDS.properties");
request.ContentLength = fileToSend.Length;
MessageBox.Show(fileToSend.Length.ToString());
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(fileToSend, 0, fileToSend.Length);
//MessageBox.Show(requestStream.);
requestStream.Close();
}
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
StreamReader reader = new StreamReader(resp.GetResponseStream());
MessageBox.Show(reader.ReadToEnd());
MessageBox.Show(resp.StatusCode.ToString());
}
我正在获取HTTP状态代码“OK”,Fiddler也显示状态200.运行这些服务后,我希望更新一些密钥,但这种情况不会发生。有谁能告诉我这个问题可能是什么?
答案 0 :(得分:0)
您是否正在使用WCF服务?如果是的话,我建议您为服务启用WCF跟踪,这将确认服务中是否发生任何异常,这似乎随后会被处理。您可以使用以下跟踪配置
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Verbose,ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp, ProcessId, ThreadId, Callstack">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
HTH, 阿米特