我試圖複製我發現這裏使用Bing的地理編碼API
:https://sqlmd.wordpress.com/2012/03/27/using-the-ssis-scripting-task-to-geocode-addresses/兵地理編碼API,SSIS,C#腳本
當我跑我有什麼,我得到這個錯誤:
Error: 0xFFFFFFFF at Get Lat Long Bing, Error:: Could not find default endpoint element that references contract 'bing.geocode.IGeocodeService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
我正在使用的腳本是C#
。
Public Sub Main()
If Dts.Variables.Contains("Address") And Dts.Variables.Contains("Lat") And Dts.Variables.Contains("Long") Then
Try
' Set a Bing Maps key before making a request
Dim key As String = "Bing Key goes here"
Dim geocodeRequest As New bing.geocode.GeocodeRequest
Dim SearchAddress As String
SearchAddress = Dts.Variables("Address").Value.ToString
Dts.Events.FireInformation(0, "Address:", SearchAddress, "", 0, True)
' Set the credentials using a valid Bing Maps Key
geocodeRequest.Credentials = New bing.geocode.Credentials()
geocodeRequest.Credentials.ApplicationId = key
' Set the full address query
geocodeRequest.Query = SearchAddress
' Set the options to only return high confidence results
Dim filters As bing.geocode.ConfidenceFilter() = New bing.geocode.ConfidenceFilter(0) {}
filters(0) = New bing.geocode.ConfidenceFilter()
filters(0).MinimumConfidence = bing.geocode.Confidence.High
Dim geocodeOptions As New bing.geocode.GeocodeOptions()
geocodeOptions.Filters = filters
geocodeRequest.Options = geocodeOptions
' Make the geocode request
Dim geocodeService As New bing.geocode.GeocodeServiceClient
Dim geocodeResponse As bing.geocode.GeocodeResponse = geocodeService.Geocode(geocodeRequest)
If geocodeResponse.Results.Length > 0 AndAlso geocodeResponse.Results(0).Locations.Length > 0 Then
Dts.Events.FireInformation(0, "Lat:", geocodeResponse.Results(0).Locations(0).Latitude.ToString(), "", 0, False)
Dts.Variables("Lat").Value = geocodeResponse.Results(0).Locations(0).Latitude
Dts.Events.FireInformation(0, "Long:", geocodeResponse.Results(0).Locations(0).Longitude.ToString(), "", 0, True)
Dts.Variables("Long").Value = geocodeResponse.Results(0).Locations(0).Longitude
End If
Catch ex As Exception
Dts.Events.FireError(-1, "Error:", ex.Message, "", 0)
Dts.TaskResult = ScriptResults.Success
End Try
Else
Dts.Events.FireError(-1, "Error:", "Missing vairable in Task Component Definition.", "", 0)
End If
End Sub
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
末級
,這是我的app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_IGeocodeService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
binding="basicHttpBinding_IGeocodeService" bindingConfiguration="basicHttpBinding_IGeocodeService"
contract="basicHttpBinding_IGeocodeService" name="basicHttpBinding_IGeocodeService" />
</client>
</system.serviceModel>
@Joey我建議你在你的問題中加入這段代碼,以獲得更多幫助。 – Svek
嘗試從配置中刪除自定義綁定並重建項目。 – Svek