我想问一个一直让我发疯的问题@_@ 我已经为 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
大家的任何回答都会让我思考更多,请给出答案。
问候, Budi Prasetyo