使用Windows Phone 8 SDK的Bing Map SOAP Service问题 [英] Bing Map SOAP Service problem with Windows Phone 8 SDK

查看:51
本文介绍了使用Windows Phone 8 SDK的Bing Map SOAP Service问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bing Map SOAP Service在Windows Phone 8上不起作用 - 启动SearchAsync时出现异常:

Bing Map SOAP Service doesn't work on Windows Phone 8 - exception when start SearchAsync:

private void BingMapSearch(int searchCount, string keyWord) { try { SearchRequest searchRequest = new SearchRequest(); searchRequest.Credentials = new Microsoft.Phone.Controls.Maps.Credentials();

searchRequest.Credentials.ApplicationId = BingMapApplicationId;
StructuredSearchQuery ssQuery = new StructuredSearchQuery();
ssQuery.Location = _latitude.ToString()+"," + _longitude.ToString(); ;
ssQuery.Keyword = keyWord;
searchRequest.StructuredQuery = ssQuery;

searchRequest.SearchOptions = new SearchOptions();
searchRequest.SearchOptions.Count = 25
searchRequest.SearchOptions.SortOrder = SortOrder.Distance;
SearchServiceClient searchService = new SearchServiceClient();
searchService.SearchCompleted + = new EventHandler< SearchCompletedEventArgs>(mapSearchService_SearchCompleted);
searchService.SearchAsync(searchRequest);
}
catch(exception ex)
{
MessageBox.Show(ex.Message," Error",MessageBoxButton.OK);
}
}

void mapSearchService_SearchCompleted(object sender,SearchCompletedEventArgs e)
{
'''
}

searchRequest.Credentials.ApplicationId = BingMapApplicationId; StructuredSearchQuery ssQuery = new StructuredSearchQuery(); ssQuery.Location = _latitude.ToString() + "," + _longitude.ToString(); ; ssQuery.Keyword = keyWord; searchRequest.StructuredQuery = ssQuery; searchRequest.SearchOptions = new SearchOptions(); searchRequest.SearchOptions.Count = 25 searchRequest.SearchOptions.SortOrder = SortOrder.Distance; SearchServiceClient searchService = new SearchServiceClient(); searchService.SearchCompleted += new EventHandler<SearchCompletedEventArgs>(mapSearchService_SearchCompleted); searchService.SearchAsync(searchRequest); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK); } } void mapSearchService_SearchCompleted(object sender, SearchCompletedEventArgs e) { ''' }

异常:

{System.ServiceModel.Dispatcher.NetDispatcherFaultException:格式化程序在尝试反序列化消息时引发异常:出现错误尝试反序列化参数

http://dev.virtualearth.net/webservices / V1 /搜索/合同:信息搜索结果
。 InnerException消息是'第1行位置错误1316.元素'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType'包含'http://dev.virtualearth.net/webservices的数据/ v1 / search:类别'
数据合同。反序列化器不知道映射到此合同的任何类型。将与"类别"对应的类型添加到已知类型列表中 - 例如,通过使用KnownTypeAttribute属性或将其添加到传递给DataContractSerializer的已知类型
列表中。'。 有关更多详细信息,请参阅InnerException。 ---> System.Runtime.Serialization.SerializationException:第1行位置错误1316.元素'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType'包含'http://的
数据dev.virtualearth.net/webservices/v1/search:Category'数据合同。反序列化器不知道映射到此合同的任何类型。将与"类别"对应的类型添加到已知类型列表中 - 例如,使用
KnownTypeAttribute属性或将其添加到传递给DataContractSerializer的已知类型列表中。

{System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://dev.virtualearth.net/webservices/v1/search/contracts:SearchResult. The InnerException message was 'Error in line 1 position 1316. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data of the 'http://dev.virtualearth.net/webservices/v1/search:Category' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Category' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: Error in line 1 position 1316. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data of the 'http://dev.virtualearth.net/webservices/v1/search:Category' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Category' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.

在Reference.cs中,它在线崩溃:

  base.EndInvoke(" Search",_ args,result)

In Reference.cs, it crashes on line:
 base.EndInvoke("Search", _args, result)

public MyNameSpace.BingMapSearchServiceReference.SearchResponse EndSearch(System.IAsyncResult result) {
                object[] _args = new object[0];
                                MyNameSpace.BingMapSearchServiceReference.SearchResponse _result = ((MyNameSpace.BingMapSearchServiceReference.SearchResponse)(base.EndInvoke("Search", _args, result)));
                return _result;
            }

该代码适用于Windows Phone 7 / Emulator。 在Windows Phone 8上反序列化响应时,它看起来有问题。在WP8上解决此问题是否有任何解决方法?

The code works with Windows Phone 7/Emulator.  It looks it is having issues when deserializing the responses on Windows Phone 8. Any work around or fix for this issue on WP8?

推荐答案

您是如何设置网络服务的? 您是否使用"添加服务引用..."创建了一个Web服务代理?向导或者您使用的是其他人放在一起的库吗?

How did you set up the web service?  Did you create a web service proxy using the "Add Service Reference..." wizard or are you using a library that someone else put together?

如果打开Visual Studio对象浏览器,加载项目,您会发现"类别"吗? class?

If you open the Visual Studio Object Browser, with your project loaded, can you find that "Category" class?

奇怪的是它可以在WP7上运行但不适用于WP8 ...

It is weird that it would work on WP7 but not WP8...

你试过吗?网络捕获,例如:使用Fiddler,看两种情况下是否返回相同的SOAP有效负载?

Have you tried getting a network capture, ex: using Fiddler, to see if the same SOAP payload is returned in both cases?


这篇关于使用Windows Phone 8 SDK的Bing Map SOAP Service问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆