Liift
2009-08-03 23:37:02 UTC
Hi I am geting Unauthorized error in my code
public static string GeocodePoint(string streetaddress)
{
MapPointService.FindServiceSoap findService = new
MapPointService.FindServiceSoap();
string latlong = "Unavailable";
//findService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
findService.Credentials = new
System.Net.NetworkCredential("panchalUjwal144176", "up1977");
findService.PreAuthenticate = true;
//Define the address specification for MWS
MapPointService.Address myAddress = new MapPointService.Address();
myAddress.FormattedAddress = streetaddress;
//Set the search options
MapPointService.FindOptions myFindOptions = new
MapPointService.FindOptions();
MapPointService.FindAddressSpecification findAddresSpec = new
MapPointService.FindAddressSpecification();
findAddresSpec.InputAddress = myAddress;
findAddresSpec.Options = myFindOptions;
//findAddresSpec.DataSourceName = "panchalUjwal144176.144176";
findAddresSpec.DataSourceName = "MapPoint.World";
//Set the ResultMask to include the rooftop geocoding values
findAddresSpec.Options.ResultMask =
MapPointService.FindResultMask.RooftopFlag |
MapPointService.FindResultMask.LatLongFlag |
MapPointService.FindResultMask.EntityFlag |
MapPointService.FindResultMask.MatchDetailsFlag |
MapPointService.FindResultMask.AddressFlag;
//Call the MWS FindAddress method
MapPointService.FindResults myFindResults =
findService.FindAddress(findAddresSpec); /* error on this line */
//Parse the Results
MapPointService.FindResult bestResult = myFindResults.Results[0];
int matchcode = 0;
MapPointService.EntityPropertyValue[] props =
bestResult.BestViewableLocation.Entity.Properties;
//Find MatchedMethod property which tells you whether rooftop
was used
for (int i = 0; i < props.Length; i++)
{
if (props[i].Name == "MatchedMethod")
{
matchcode = System.Convert.ToInt32(props[i].Value);
}
}
//Prepare result
if (matchcode == 7)
{
latlong = "new VELatLong(" +
bestResult.BestViewableLocation.LatLong.Latitude
+ ", " + bestResult.BestViewableLocation.LatLong.Longitude + ")";
}
return latlong;
}
I check my account in Bling Maps Enterpise for Account .They say my Account
is set up properly. So Can you please tell me where I am going wrong.
public static string GeocodePoint(string streetaddress)
{
MapPointService.FindServiceSoap findService = new
MapPointService.FindServiceSoap();
string latlong = "Unavailable";
//findService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
findService.Credentials = new
System.Net.NetworkCredential("panchalUjwal144176", "up1977");
findService.PreAuthenticate = true;
//Define the address specification for MWS
MapPointService.Address myAddress = new MapPointService.Address();
myAddress.FormattedAddress = streetaddress;
//Set the search options
MapPointService.FindOptions myFindOptions = new
MapPointService.FindOptions();
MapPointService.FindAddressSpecification findAddresSpec = new
MapPointService.FindAddressSpecification();
findAddresSpec.InputAddress = myAddress;
findAddresSpec.Options = myFindOptions;
//findAddresSpec.DataSourceName = "panchalUjwal144176.144176";
findAddresSpec.DataSourceName = "MapPoint.World";
//Set the ResultMask to include the rooftop geocoding values
findAddresSpec.Options.ResultMask =
MapPointService.FindResultMask.RooftopFlag |
MapPointService.FindResultMask.LatLongFlag |
MapPointService.FindResultMask.EntityFlag |
MapPointService.FindResultMask.MatchDetailsFlag |
MapPointService.FindResultMask.AddressFlag;
//Call the MWS FindAddress method
MapPointService.FindResults myFindResults =
findService.FindAddress(findAddresSpec); /* error on this line */
//Parse the Results
MapPointService.FindResult bestResult = myFindResults.Results[0];
int matchcode = 0;
MapPointService.EntityPropertyValue[] props =
bestResult.BestViewableLocation.Entity.Properties;
//Find MatchedMethod property which tells you whether rooftop
was used
for (int i = 0; i < props.Length; i++)
{
if (props[i].Name == "MatchedMethod")
{
matchcode = System.Convert.ToInt32(props[i].Value);
}
}
//Prepare result
if (matchcode == 7)
{
latlong = "new VELatLong(" +
bestResult.BestViewableLocation.LatLong.Latitude
+ ", " + bestResult.BestViewableLocation.LatLong.Longitude + ")";
}
return latlong;
}
I check my account in Bling Maps Enterpise for Account .They say my Account
is set up properly. So Can you please tell me where I am going wrong.