我编写了一个 Silverlight 类来使用 Bing 地图路由服务。我正在从存储在数据库中的纬度/经度数据创建一个 Waypoint 对象数组,并将其发送到 Web 服务的 CalculateRoute 方法以获取路由,但我无法成功获取路由. 响应始终包含错误“处理请求时发生错误”。我难住了。关于如何解决此问题或至少从服务中获得更有用的错误/异常的任何想法?这是调用服务的方法:
public void CalculateRoute(Waypoint[] waypoints)
{
request = new RouteRequest();
request.Waypoints = new ObservableCollection<Waypoint>();
for (int idx = 0; idx < waypoints.Length; idx++)
{
request.Waypoints.Add(waypoints[idx] as Waypoint);
}
request.ExecutionOptions = new ExecutionOptions();
request.ExecutionOptions.SuppressFaults = true;
request.Options = new RouteOptions();
request.Options.Optimization = RouteOptimization.MinimizeTime;
request.Options.RoutePathType = RoutePathType.Points;
request.Options.Mode = TravelMode.Walking;
request.Options.TrafficUsage = TrafficUsage.TrafficBasedRouteAndTime;
_map.CredentialsProvider.GetCredentials(
(Credentials credentials) =>
{
request.Credentials = credentials;
RouteClient.CalculateRouteAsync(request);
});
}
然后我有一个处理响应的回调,但我一直无法获得成功的响应。我已尝试确保正确设置 maxBufferSize 和 maxReceivedMessageSize 并且正确设置超时,但无济于事。任何帮助将非常感激。