Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 401: Unauthorized error in geospatial select state

Author  Topic 

vikysaran
Starting Member

1 Post

Posted - 2010-08-27 : 04:43:12
Hi,
I'm new to GeoSpatial coding. i found a sample code at [url]http://msdn.microsoft.com/en-us/magazine/dd434647.aspx[/url] and trying to run its 'catalog_geocoder.sql' file. All is going well but on the select statement it is giving error bellow-


Msg 6522, Level 16, State 2, Line 2
A .NET Framework error occurred during execution of user-defined routine or aggregate "geocode":
System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
System.Net.WebException:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at MappointGeocoder.MapPointRef.FindServiceSoap.FindAddress(FindAddressSpecification specification)
at Spatial.MpGeocoder.Geocode(String streetAddress)


Here I'm pasting the code


alter database pubs set trustworthy on
go

use pubs
go

sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

create assembly geocode from 'C:\temp\MappointGeocoder.dll'
with permission_set = external_access
go

create assembly ser from 'C:\temp\MappointGeocoder.XmlSerializers.dll'
with permission_set = safe
go

create function dbo.geocode (@address nvarchar(4000))
returns nvarchar(100)
as
external name geocode.[Spatial.MpGeocoder].Geocode
go

select dbo.Geocode('One Microsoft Way, Redmond, WA 98052');
go


create function GeocodePoint(@address varchar(100))
returns geography
as
begin
declare @g geography;
select @g = geography::STPointFromText(dbo.Geocode(@address), 0);
return @g
end
go

select dbo.GeocodePoint('One Microsoft Way, Redmond, WA 98052').ToString();
go


Also i placed the files into c:/Temp as i mentioned the path above. Here both select statements are giving same error.
Please help ASAP

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-27 : 05:09:34
There is an error in your CLR. Are you geocoding against Google?
Do you have the appropriate API Key? You can only geocode 12000-15000 addresses per 24 hour.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-27 : 05:13:04
Copied from the source code in the link above
quote:
To run this sample you must have a MapPoint Developer Account.
Visit https://mappoint-css.live.com/mwssignup/Default.aspx?wa=wsignin1.0 to obtain this account.

Once you have obtained the account, change the code in Geocoder.cs to add your userid and password.
Uncomment the code for a proxy server if you use a proxy server, and recompile the .NET assembly.

This format mandates the order of coordinates as "longitude, latitude" rather than "latitude, longitude".
This is suitable for use with SQL Server's GEOGRAPHY data type.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -