我使用下面给出的代码在 Bing Maps 上绘制路线。当系统直接连接到互联网时,它在模拟器上运行良好。但是当我在我公司的代理下的代码的倒数第二行时,它会抛出异常说:需要代理授权:407
BingMaps.RouteService.RouteServiceClient routeService = new BingMaps.RouteService.RouteServiceClient("BasicHttpBinding_IRouteService");
BingMaps.RouteService.RouteRequest RouteReq = new BingMaps.RouteService.RouteRequest();
RouteReq.Credentials = new BingMaps.RouteService.Credentials();
RouteReq.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)Map.CredentialsProvider).ApplicationId;
RouteOptions rOptions = new RouteOptions();
rOptions.Mode = TravelMode.Driving;
rOptions.Optimization = RouteOptimization.MinimizeDistance;
RouteReq.Options = rOptions;
RouteReq.Options.RoutePathType = BingMaps.RouteService.RoutePathType.Points;
// Set the waypoints of the route to be calculated using the Geocode Service results stored in the geocodeResults variable.
RouteReq.Waypoints = new System.Collections.ObjectModel.ObservableCollection<Waypoint>();
foreach (Waypoint wp in WPList)
{
RouteReq.Waypoints.Add(wp);
}
//routeService.ClientCredentials = new System.ServiceModel.Description.ClientCredentials( new NetworkCredential("461167", "July@2012", "india");
routeService.CalculateRouteAsync(RouteReq);
routeService.CalculateRouteCompleted += new EventHandler<CalculateRouteCompletedEventArgs>(RouteService_CalculateRouteCompleted);
我知道我需要设置代理,但是我不知道如何设置。因为 RouteService 未配置接受代理凭据。
互联网在模拟器上也可以正常工作,我还在模拟器上设置了代理凭据。
请建议如何做到这一点,否则不可能,因为它没有使用模拟器的代理凭据,甚至没有使用系统上存储的凭据。