C# 如何向虚拟地球路由web服务发送多个航路点

C# 如何向虚拟地球路由web服务发送多个航路点,c#,web-services,bing-maps,bing,virtual-earth,C#,Web Services,Bing Maps,Bing,Virtual Earth,我正在尝试使用虚拟地球web服务: 返回在多个点停止的车辆的总行程距离 我的代码适用于具有4个航路点的旅行,但除此之外,我会遇到以下错误: 的最大邮件大小配额 已收到传入消息(65536) 超过。要增加配额,请使用 上的MaxReceivedMessageSize属性 适当的绑定元素 大致代码是:(C#控制台应用程序) 使用系统; 使用System.Collections.Generic; 使用System.Linq; 使用System.Xml; 使用系统文本; 使用系统配置; 使用系统线程;

我正在尝试使用虚拟地球web服务:

返回在多个点停止的车辆的总行程距离

我的代码适用于具有4个航路点的旅行,但除此之外,我会遇到以下错误:

的最大邮件大小配额 已收到传入消息(65536) 超过。要增加配额,请使用 上的MaxReceivedMessageSize属性 适当的绑定元素

大致代码是:(C#控制台应用程序)

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Xml;
使用系统文本;
使用系统配置;
使用系统线程;
使用System.Text.RegularExpressions;
使用altRouteFinder.VEStagingToken;
使用altRouteFinder.VERoutingService;
名称空间altRouteFinder
{
班级计划
{
静态void Main(字符串[]参数)
{
waypointString=“53.450356,-2.873335;53.399184,-2.980577;53.440535,-2.864101;53.449368,-2.885361;53.454417,-2.930646;53.450356,-2.873335”;
string[]points=waypointString.Split(“;”);
航路点[]航路点=新航路点[点.长度];
双日距=0;
int pointIndex=-1;
foreach(以点为单位的字符串点)
{
pointIndex++;
航路点[点索引]=新航路点();
字符串[]位=点分割(',');
航路点[pointIndex].Location=new VERoutingService.Location();
航路点[pointIndex].Location.Latitude=double.Parse(数字[0].Trim());
航路点[pointIndex].Location.Longitude=double.Parse(数字[1].Trim());
if(pointIndex==0)
航路点[pointIndex].Description=“开始”;
else if(pointIndex==points.Length)
航路点[pointIndex]。Description=“End”;
其他的
航路点[pointIndex].Description=string.Format(“停止{0}”,pointIndex);
}
RouterRequest.Waypoints=航路点;
RouteOptions myRouteOptions=新RouteOptions();
//设置行驶模式-驾驶或步行
myRouteOptions.Mode=TravelMode.Driving;
//设置优化类型-MinimizeInstance或MinimizeTime
myRouteOptions.Optimization=RouteOptimization.Minimetime;
//设置流量条件的使用-TrafficBasedTime、TrafficBasedTime或None
myRouteOptions.TrafficUsage=TrafficUsage.TrafficBasedTime;
//将管线选项传递给管线对象
Options=myRouteOptions;
//进行计算路由请求
RouteServiceClient routeService=新RouteServiceClient();
RouterResponse RouterResponse=routeService.CalculateRoute(RouterRequest);
//遍历每个行程项目以获取路线方向
StringBuilder方向=新StringBuilder(“”);
如果(RouterResponse.Result.Legs.Length>0)
{
int指令计数=0;
int-legCount=0;
foreach(RouteLeg leg leg in routerresponse.Result.Legs)
{
legCount++;
Append(string.Format(“Leg{0}\n”,legCount));
foreach(航段中的行程项目。行程)
{
指令计数++;
Append(string.Format(“{0}.{1}{2}\n”,
指令计数,item.Summary.Distance,item.Text);
Dayddistance+=item.Summary.Distance;
}
}
//删除关键字周围的所有Bing地图标签。
//如果要格式化结果,可以使用标记
正则表达式正则表达式=新正则表达式(“,
RegexOptions.IgnoreCase | RegexOptions.Multiline);
结果=regex.Replace(directions.ToString(),string.Empty);
}
其他的
结果=“未找到路线”;
控制台写入线(结果);
控制台写入线(日距离);
}
}
}

我不知道在哪里设置MaxReceivedMessageSize plus我读到它只在Vista上工作

帮助任何人?

我在这里找到了解决方案:


MaxReceivedMessageSize位于应用程序的.config文件中,即web.config或app.config等。

您可以在WPF中的
app.config
和asp中的
web.config
中执行此操作

诀窍是,
maxBufferSize
也必须等于
maxReceivedMessageSize

。我对此进行了测试,并得到了世界各地的方向列表

<binding name="BasicHttpBinding_IRouteService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">

<binding name="BasicHttpBinding_IRouteService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">