Once the job is complete, it's time to fetch its results. How are we going to do this? You guessed it right: we need to make another call to the Dataflow API, using the link we extracted earlier.
public static void GetResult(string dataFlowLink, string responseFilePath) { var settings = new XmlWriterSettings(); settings.Indent = true; using (var writer = XmlWriter.Create(responseFilePath, settings)) { var uri = String.Format("{0}?output=xml&key={1}", dataFlowLink, Settings.Key); var xdoc = XDocument.Load(uri); xdoc.WriteTo(writer); } }
As before, we add our Bing Maps Key to the URL template, and specify XML as output. We use XDocument
again to fetch the data, which we then store on a file inside the Data
folder. We can then store the data in a database, or some other data store, and then match the requested addresses with their corresponding responses.
The job's result is as follows (a sample file, dataResponse.xml
, can be...