【问题标题】:Windows phone 8 CommunicationException The remote server returned an error: NotFoundWindows phone 8 CommunicationException 远程服务器返回错误:NotFound
【发布时间】:2013-10-16 10:04:28
【问题描述】:

我想问一个一直让我抓狂的问题@_@ 我为 windows phone 8 制作了一个从 wcf 服务检索数据的应用程序。 幸运的是,我的办公室同事让我为它服务。但是,当我使用该服务时,我得到了这个错误。

System.ServiceModel.CommunicationException was unhandled by user code
  HResult=-2146233087
  Message=The remote server returned an error: NotFound.
  Source=System.ServiceModel
  StackTrace:
       at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
       at NavFinance.NavFinData.NavcoreNavfinServiceClient.NavcoreNavfinServiceClientChannel.EndGetAll(IAsyncResult result)
       at NavFinance.NavFinData.NavcoreNavfinServiceClient.NavFinance.NavFinData.INavcoreNavfinService.EndGetAll(IAsyncResult result)
       at NavFinance.NavFinData.NavcoreNavfinServiceClient.OnEndGetAll(IAsyncResult result)
       at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
  InnerException: System.Net.WebException
       HResult=-2146233079
       Message=The remote server returned an error: NotFound.
       Source=System.Windows
       StackTrace:
            at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
            at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
            at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
       InnerException: System.Net.WebException
            HResult=-2146233079
            Message=The remote server returned an error: NotFound.
            Source=System.Windows
            StackTrace:
                 at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                 at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
                 at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
            InnerException:

在这里和那里搜索之后,我得到了这篇好文章。 http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx

但是,我读了它,仍然不明白。为什么? 因为我的服务是用 C# 类编写的,而不是作为 Web 服务。所以我找不到 IIS 服务。

这是我生成数据的代码。

public PurchaseInvoiceMainPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(purchaseInvoice_Loaded);
        }

        private void purchaseInvoice_Loaded(object sender, RoutedEventArgs e)
        {
            NavcoreNavfinServiceClient client = new NavcoreNavfinServiceClient();
            client.GetAllCompleted += new EventHandler<GetAllCompletedEventArgs>(client_getAllPurchaseInvoice);
            client.GetAllAsync("509A7214-D3A9-47E7-9BB4-232E670ED650");
        }

        private void client_getAllPurchaseInvoice(object sender, GetAllCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                purchaseDataList.ItemsSource = e.Result;
            }
        }

而且,这是我返回结果的服务。

public System.Collections.ObjectModel.ObservableCollection<NavFinance.NavFinData.vwPurchaseInvoice> EndGetAll(System.IAsyncResult result) {
                object[] _args = new object[0];
                System.Collections.ObjectModel.ObservableCollection<NavFinance.NavFinData.vwPurchaseInvoice> _result = ((System.Collections.ObjectModel.ObservableCollection<NavFinance.NavFinData.vwPurchaseInvoice>)(base.EndInvoke("GetAll", _args, result)));
                return _result;
            }

我在这一行得到了例外。

System.Collections.ObjectModel.ObservableCollection<NavFinance.NavFinData.vwPurchaseInvoice> _result = ((System.Collections.ObjectModel.ObservableCollection<NavFinance.NavFinData.vwPurchaseInvoice>)(base.EndInvoke("GetAll", _args, result)));

我使用了很多我发现的技巧,从增大 maxbytes 等开始。 它仍然不起作用。 有人请帮助我。我真的很困惑TT_TT

这是我使用的服务。

http://dev.navcore.com/NavFinWebService/Navcore.Navfin.Service.NavcoreNavfinService.svc

大家的任何回答都会让我思考更多,请给出答案。

问候, 布迪普拉塞约

【问题讨论】:

  • 我也面临这个问题

标签: c# wcf windows-phone-8 windows-phone wcf-data-services


【解决方案1】:

此错误表明您的应用程序无法与服务通信。您是否在手机/模拟器 Internet Explorer 中尝试服务 URL 以确保该 URL 可访问?

【讨论】:

  • 我已经尝试过了,这很有效。我在模拟器上使用 IE 打开服务。但是,我使用可以使模拟器连接到互联网的 wifi 连接。对吗?
  • @josue Yeray,这个问题可能有什么问题?
  • @BudiPrasetyo windows phone 模拟器是一个虚拟机,要在 windows 机器上使用服务,你需要确保防火墙允许 80 端口的连接,最好使用你的机器 IP 作为网址...
【解决方案2】:

哇,太棒了..!! 在为这个错误困扰了 3 天之后,终于找到了一些东西。 :)

所有功劳都应归功于Josue Yeray 非常感谢,为什么我没有意识到那个错误。 最后,我只能通过将模拟器连接到互联网来从我的服务中获取数据。

就我而言,通常我使用有线连接,而这在模拟器上根本不起作用。 搜索后,我将连接更改为无线连接。 然后,它的工作和完成。

非常感谢。 :)

【讨论】:

    【解决方案3】:

    什么都不做,只需关闭公共和私人防火墙,然后等待 2-3 分钟,然后运行应用程序。它将完美运行。

    我做到了,它奏效了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-22
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 2011-12-30
      相关资源
      最近更新 更多