Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Net.WebException:远程服务器返回错误:NotFound(Windows Phone)_C#_Web Services_Windows Phone 7_Windows Phone - Fatal编程技术网

C# System.Net.WebException:远程服务器返回错误:NotFound(Windows Phone)

C# System.Net.WebException:远程服务器返回错误:NotFound(Windows Phone),c#,web-services,windows-phone-7,windows-phone,C#,Web Services,Windows Phone 7,Windows Phone,我正在Windows Phone应用程序中调用web服务,但由于某些原因,我随机得到以下错误。还值得一提的是,我只是通过应用程序得到这个。当我在浏览器中运行完全相同的web服务调用时,一切都会完美地工作 “System.Net.WebException:远程服务器返回错误:NotFound。\r\n在System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)\r\n在System

我正在Windows Phone应用程序中调用web服务,但由于某些原因,我随机得到以下错误。还值得一提的是,我只是通过应用程序得到这个。当我在浏览器中运行完全相同的web服务调用时,一切都会完美地工作

“System.Net.WebException:远程服务器返回错误:NotFound。\r\n在System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)\r\n在System.Net.Browser.ClientHttpWebRequest.c\u DisplayClass2.b\u 1(对象发送状态)\r\n在System.Net.Browser.AsyncHelper.c\u DisplayClass4.b\u 0(对象发送状态)\r\n位于System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi、对象obj、BindingFlags invokeAttr、绑定器绑定器、对象参数、CultureInfo区域性、Boolean isBinderDefault、程序集调用者、Boolean verifyAccess、StackCrawlMark和stackMark)\r\n位于System.Reflection.RuntimeMethodInfo.InternalInvoke(对象obj,BindingFlags invokeAttr,Binder Binder,对象[]参数,CultureInfo区域性,堆栈爬网标记和堆栈标记)\r\n位于System.Reflection.MethodBase.Invoke(对象obj,对象[]参数)\r\n位于System.Delegate.DynamicInvokeOne(对象[]参数)\r\n位于System.MulticastDelegate.DynamicInvokeImpl(对象[]参数)\r\n位于System.Delegate.DynamicInvoke(对象[]args)\r\n位于System.Windows.Threading.Dispatcher.c\u DisplayClass4.b\u 3()\r\n位于System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi,Object obj,BindingFlags invokeAttr,BindingBinder,Object参数,CultureInfo区域性,Boolean isBinderDefault,程序集调用者,Boolean verifyAccess,StackScrawMark&stackMark)\r\n位于System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,BindingFlags invokeAttr,Binder Binder Binder,Object[]参数,CultureInfo区域性,StackScrawlMark&stackMark)\r\n位于System.Reflection.MethodBase.Invoke(对象对象对象,对象[]参数)\r\n位于System.Delegate.DynamicInvokeOne(对象[]args)\r\n位于System.MulticastDelegate.DynamicInvokeImpl(对象[]args)\r\n位于System.Delegate.DynamicInvoke(对象[]args)\r\n位于System.Windows.Threading.DispatcherOperation.Invoke()\r\n位于System.Windows.Threading.Dispatcher.Dispatcher(DispatcherPriority priority)\r\n位于System.Windows.Threading.Dispatcher.OnInvoke(对象上下文)\r\n位于System.Windows.Hosting.CallbackCookie.Invoke(对象[]参数)\r\n位于System.Windows.Hosting.DelegateWrapper.InternalInvoke(对象[]args)\r\n位于System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr幻象、Int32 nParamCount、ScriptParam[]pParams、ScriptParam&PreSalt)\r\n


如果有人能帮助我,我将不胜感激!谢谢..

API调用是否需要为请求添加任何额外的HTTP头?@NeilTurner-一点也不需要。只是一个带有URL中参数的基本GET请求…:\也作为旁注。有时这会起作用,第二天如果不更改任何代码,它将不会…@Relborg,如果是这样的话有时,如果不更改任何代码,这将无法工作,我认为最可能的原因是服务器响应速度不够快。在windows phone中,如果超时过期,您将收到404错误(这里没有逻辑,lol)。由于WebClient不支持超时,您应该开始使用HttpWebRequest或寻找第三方UTIL。
public void detailsWebService(bool isLastListing, string sessionID, Result listing, DownloadStringCompletedEventHandler callback)
    {
        //Url to result servlet
        string servletUrl = string.Format(baseURL + "Something/patient?sid={0}&patientGuid={1}&format=JSON",
            Uri.EscapeDataString(sessionID),
            Uri.EscapeDataString(listing.GUID));

        //Calls Servlet
        WebClient client = new WebClient();            
        client.DownloadStringCompleted += callback;
        client.DownloadStringAsync(new Uri(servletUrl, UriKind.Absolute), patientGuidAndLastListing);
    }