javier cabrera
2009-07-10 22:29:10 UTC
Hi, I always get findStartResults.NumberFound!= 0
this is my code, what am I doing wrong?
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using mappoint;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
RenderServiceSoap renderService=new RenderServiceSoap();
FindServiceSoap findService=new FindServiceSoap();
RouteServiceSoap routeService=new RouteServiceSoap();
CommonServiceSoap commonService=new CommonServiceSoap();
/// <summary>
/// An instance of the render service class
/// </summary>
public RenderServiceSoap RenderService
{
get
{
return renderService;
}
}
/// <summary>
/// An instance of the find service class
/// </summary>
public FindServiceSoap FindService
{
get
{
return findService;
}
}
/// <summary>
/// An instance of the route service class
/// </summary>
public RouteServiceSoap RouteService
{
get
{
return routeService;
}
}
/// <summary>
/// An instance of the common service class
/// </summary>
public CommonServiceSoap CommonService
{
get
{
return commonService;
}
}
protected void Page_Load(object sender, EventArgs e)
{
NetworkCredential ourcredential = new
NetworkCredential(ConfigurationManager.AppSettings["MPUser"],
ConfigurationManager.AppSettings["MPPass"]);
NetworkCredential proxycredential=new
NetworkCredential(ConfigurationManager.AppSettings["PrUser"],
ConfigurationManager.AppSettings["PrPass"]);
//renderService.Credentials = ourcredential;
//renderService.PreAuthenticate = true;
FindSpecification startspec = new FindSpecification();
startspec.DataSourceName = "MapPoint.EU";
//startspec.InputPlace = "900 7th Street Wichita Falls, Texas
76301";
startspec.InputPlace = "Milan";
FindResults findStartResults = new FindResults();
FindSpecification endspec = new FindSpecification();
endspec.DataSourceName = "MapPoint.EU";
//endspec.InputPlace = "501 Sheppard Burkburnett, Texas 76354";
endspec.InputPlace = "Milan";
FindResults findEndResults = new FindResults();
try
{
findService.Credentials = ourcredential;
findService.PreAuthenticate = true;
findService.Proxy = new WebProxy("proxy.abaseguros.com",80);
findService.Proxy.Credentials = proxycredential;
// Find the start and end points.
findStartResults = FindService.Find(startspec);
findEndResults = FindService.Find(endspec);
}
catch (System.Web.Services.Protocols.SoapException exception)
{
// Your exception processing goes here.
txtError.Text = "hay error";
}
// Verify that both find requests returned results.
if( findStartResults.NumberFound!= 0 && findEndResults.NumberFound !
= 0)
{
// If there were results, use the first one.
LatLong[]myWPs = new LatLong[2];
myWPs[0] = findStartResults.Results[0].FoundLocation.LatLong;
myWPs[1] = findEndResults.Results[0].FoundLocation.LatLong;
try
{
routeService.Credentials = ourcredential;
routeService.PreAuthenticate = true;
routeService.Proxy = new WebProxy("proxy.abaseguros.com",
80);
routeService.Proxy.Credentials = proxycredential;
// Create a route between the two points and save it to a session
variable.
Route returnedRoute;
returnedRoute = RouteService.CalculateSimpleRoute(myWPs,
"", SegmentPreference.Quickest);
Cache["userRoute"] = returnedRoute;
// Redirect to the directions page.
Response.Redirect("Directions.aspx");
}
catch(System.Web.Services.Protocols.SoapException exception)
{
if (exception.Detail["Type"].InnerText ==
"MapPointUnroutableException")
{
txtError.Text = "The two place names are unroutable.
";
}
else
{
// Your exception processing goes here.
txtError.Text = "hay error2";
}
}
}
else
{
// Inform the user if no results were found.
txtError.Text = "No results were found for either the Start
or End place names.";
}
}
}
url:http://www.ureader.com/gp/1621-1.aspx
this is my code, what am I doing wrong?
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using mappoint;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
RenderServiceSoap renderService=new RenderServiceSoap();
FindServiceSoap findService=new FindServiceSoap();
RouteServiceSoap routeService=new RouteServiceSoap();
CommonServiceSoap commonService=new CommonServiceSoap();
/// <summary>
/// An instance of the render service class
/// </summary>
public RenderServiceSoap RenderService
{
get
{
return renderService;
}
}
/// <summary>
/// An instance of the find service class
/// </summary>
public FindServiceSoap FindService
{
get
{
return findService;
}
}
/// <summary>
/// An instance of the route service class
/// </summary>
public RouteServiceSoap RouteService
{
get
{
return routeService;
}
}
/// <summary>
/// An instance of the common service class
/// </summary>
public CommonServiceSoap CommonService
{
get
{
return commonService;
}
}
protected void Page_Load(object sender, EventArgs e)
{
NetworkCredential ourcredential = new
NetworkCredential(ConfigurationManager.AppSettings["MPUser"],
ConfigurationManager.AppSettings["MPPass"]);
NetworkCredential proxycredential=new
NetworkCredential(ConfigurationManager.AppSettings["PrUser"],
ConfigurationManager.AppSettings["PrPass"]);
//renderService.Credentials = ourcredential;
//renderService.PreAuthenticate = true;
FindSpecification startspec = new FindSpecification();
startspec.DataSourceName = "MapPoint.EU";
//startspec.InputPlace = "900 7th Street Wichita Falls, Texas
76301";
startspec.InputPlace = "Milan";
FindResults findStartResults = new FindResults();
FindSpecification endspec = new FindSpecification();
endspec.DataSourceName = "MapPoint.EU";
//endspec.InputPlace = "501 Sheppard Burkburnett, Texas 76354";
endspec.InputPlace = "Milan";
FindResults findEndResults = new FindResults();
try
{
findService.Credentials = ourcredential;
findService.PreAuthenticate = true;
findService.Proxy = new WebProxy("proxy.abaseguros.com",80);
findService.Proxy.Credentials = proxycredential;
// Find the start and end points.
findStartResults = FindService.Find(startspec);
findEndResults = FindService.Find(endspec);
}
catch (System.Web.Services.Protocols.SoapException exception)
{
// Your exception processing goes here.
txtError.Text = "hay error";
}
// Verify that both find requests returned results.
if( findStartResults.NumberFound!= 0 && findEndResults.NumberFound !
= 0)
{
// If there were results, use the first one.
LatLong[]myWPs = new LatLong[2];
myWPs[0] = findStartResults.Results[0].FoundLocation.LatLong;
myWPs[1] = findEndResults.Results[0].FoundLocation.LatLong;
try
{
routeService.Credentials = ourcredential;
routeService.PreAuthenticate = true;
routeService.Proxy = new WebProxy("proxy.abaseguros.com",
80);
routeService.Proxy.Credentials = proxycredential;
// Create a route between the two points and save it to a session
variable.
Route returnedRoute;
returnedRoute = RouteService.CalculateSimpleRoute(myWPs,
"", SegmentPreference.Quickest);
Cache["userRoute"] = returnedRoute;
// Redirect to the directions page.
Response.Redirect("Directions.aspx");
}
catch(System.Web.Services.Protocols.SoapException exception)
{
if (exception.Detail["Type"].InnerText ==
"MapPointUnroutableException")
{
txtError.Text = "The two place names are unroutable.
";
}
else
{
// Your exception processing goes here.
txtError.Text = "hay error2";
}
}
}
else
{
// Inform the user if no results were found.
txtError.Text = "No results were found for either the Start
or End place names.";
}
}
}
url:http://www.ureader.com/gp/1621-1.aspx