<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Virtual Earth</title>
        <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/category/59.aspx</link>
        <description>Virtual Earth</description>
        <language>en-US</language>
        <copyright>Shawn Weisfeld</copyright>
        <generator>Subtext Version 2.1.2.2</generator>
        <item>
            <title>Address Validation/Normalization Using Virtual Earth </title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2007/11/15/finding-addresses-using-virtual-earth.aspx</link>
            <description>&lt;p&gt;So everyone loves the snazzy demo of Virtual Earth where they in a few lines of HTML and JavaScript draw a map (&lt;a title="http://dev.live.com/virtualearth/sdk/" href="http://dev.live.com/virtualearth/sdk/"&gt;http://dev.live.com/virtualearth/sdk/&lt;/a&gt;). But what about doing some hard stuff, what if you want to  "validate" the addresses in your address book to ensure that they are correct. Well Virtual Earth can help you here also. They have a suite of web services (&lt;a title="http://msdn2.microsoft.com/en-us/library/aa286513.aspx" href="http://msdn2.microsoft.com/en-us/library/aa286513.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa286513.aspx&lt;/a&gt;) that you can do all kinds of stuff with. In my case I want to throw it a string that could be an address and get what it thinks the most likely "real" address is for that string. &lt;/p&gt; &lt;p&gt;Lets say for example I had the address "400 orange orlando, fl 32810" as you can see I don't know what type of street it is (RD, LN, etc.) and I also don't have the extended zip code. Well with a few lines of code I can pass that address to Virtual Earth and they will give me back a list of possible choices.&lt;/p&gt; &lt;p&gt;FYI at the time of writing this post they are re-branding this service, changing its name from MapPoint Web Service to Virtual Earth so you might need to use the old name if searching for more information on this topic.&lt;/p&gt; &lt;p&gt;Step 1: go to &lt;a title="https://mappoint-css.live.com/CSCV3" href="https://mappoint-css.live.com/CSCV3"&gt;https://mappoint-css.live.com/CSCV3&lt;/a&gt; and sign up for a developer account. This will take a while since they need to provision your account. &lt;/p&gt; &lt;p&gt;Step 2: go to the verify credentials screen in the VE admin console where you created your account and test your password to ensure that everything has been setup and is working. (DONT FORGET THIS STEP!!!)&lt;/p&gt; &lt;p&gt;Step 3: using the WSDL URL from that screen create a web service reference in your .NET application&lt;/p&gt; &lt;p&gt;Step 4: Write the code! Here you can see that I new up a instance of my service and pass it some credentials. Then I create an address object with the address that I want to "validate". I then put that address object into an address specification that tell VE to look in North America for that address. Finally I call the service to get the results and iterate over them printing them to the console. &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(43,145,175)"&gt;FindServiceSoap&lt;/span&gt; findService = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;FindServiceSoap&lt;/span&gt;();
findService.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; System.Net.&lt;span style="color: rgb(43,145,175)"&gt;NetworkCredential&lt;/span&gt;(&lt;span style="color: rgb(163,21,21)"&gt;"Web Service Account ID"&lt;/span&gt;, &lt;span style="color: rgb(163,21,21)"&gt;"Password"&lt;/span&gt;);

&lt;span style="color: rgb(43,145,175)"&gt;Address&lt;/span&gt; myAddress = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Address&lt;/span&gt;();
myAddress.FormattedAddress = &lt;span style="color: rgb(163,21,21)"&gt;"400 orange orlando, fl 32810"&lt;/span&gt;;

&lt;span style="color: rgb(43,145,175)"&gt;FindAddressSpecification&lt;/span&gt; findAddressSpec = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;FindAddressSpecification&lt;/span&gt;();
findAddressSpec.InputAddress = myAddress;
findAddressSpec.DataSourceName = &lt;span style="color: rgb(163,21,21)"&gt;"MapPoint.NA"&lt;/span&gt;;

&lt;span style="color: rgb(43,145,175)"&gt;FindResults&lt;/span&gt; foundAddressResults = findService.FindAddress(findAddressSpec);

&lt;span style="color: rgb(0,0,255)"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43,145,175)"&gt;FindResult&lt;/span&gt; fr &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; foundAddressResults.Results)
{
    &lt;span style="color: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(fr.FoundLocation.Address.FormattedAddress); 
}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/219.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>sweisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2007/11/15/finding-addresses-using-virtual-earth.aspx</guid>
            <pubDate>Thu, 15 Nov 2007 16:12:00 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/219.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2007/11/15/finding-addresses-using-virtual-earth.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/219.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/219.aspx</trackback:ping>
        </item>
    </channel>
</rss>
