发现WP8服务器错误

时间:2013-09-15 02:55:48

标签: json post windows-phone-8 webclient

我正在尝试将JSON数据发布到我的WCF服务,但是我收到了Not Found错误。

代码:

    public void ReportSighting()
    {
        var uri = new Uri("http://demo.notifysolutions.com/MobileService.svc/ReportSighting", UriKind.Absolute);

        var webClient = new WebClient();
        webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
        webClient.Encoding = Encoding.UTF8;
        webClient.Headers[HttpRequestHeader.ContentLength] = jsonData.Length.ToString();
        webClient.AllowWriteStreamBuffering = true;
        webClient.UploadStringAsync(uri, "POST", jsonData);
        webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(ReportSightingCompleted);
        System.Threading.Thread.Sleep(200);
    }

    private void PostCompleted(object sender, UploadStringCompletedEventArgs e)
    {
        try
        {
            MessageBox.Show(e.Result);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    } 

错误: InnerException = {System.Net.WebException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。    在System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)    在Syst ...

我在Fiddler尝试了这个,它运行正常。

0 个答案:

没有答案