0

我正在执行以下代码

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。运行这些服务后,我希望更新一些键,但没有发生。有人可以让我知道问题可能是什么吗?

4

1 回答 1

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,阿米特

于 2012-10-18T18:13:48.187 回答