<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Asp.Net Team's Weblog &#187; XML</title>
	<atom:link href="http://aspnetteam.wordpress.com/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://aspnetteam.wordpress.com</link>
	<description>Another ASP.NET Weblog</description>
	<lastBuildDate>Thu, 03 Sep 2009 11:54:33 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='aspnetteam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/ea6345954410fcd98c45fab481df7cbf?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Asp.Net Team's Weblog &#187; XML</title>
		<link>http://aspnetteam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://aspnetteam.wordpress.com/osd.xml" title="Asp.Net Team&#8217;s Weblog" />
		<item>
		<title>Using Web Services: How to Consume</title>
		<link>http://aspnetteam.wordpress.com/2008/09/16/using-web-services-how-to-consume/</link>
		<comments>http://aspnetteam.wordpress.com/2008/09/16/using-web-services-how-to-consume/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 17:54:21 +0000</pubDate>
		<dc:creator>Frank Adams</dc:creator>
				<category><![CDATA[WebServices]]></category>
		<category><![CDATA[Consume]]></category>
		<category><![CDATA[DataBind]]></category>
		<category><![CDATA[DataView]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://aspnetteam.wordpress.com/?p=34</guid>
		<description><![CDATA[Ever wonder how to consume a web service.  I'll tell you how. Read on. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetteam.wordpress.com&blog=4774049&post=34&subd=aspnetteam&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">Consuming a web service is easier that creating one. All you have to do is create a reference and then add a couple of lines of code and you have the web service to use in your application. </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">The way to add a web reference to your web service is to first figure out where the web service resides.<span>  </span>It can be a full web address or it can be a local folder.<span>  </span>Once you figure that out you need to create a reference to it. To do this:</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">Right click on the project and select add web reference. When you do this you are presented with a box &#8211; Add Web Reference. From here you will choose the correct link under Browse to: and select the web service you will use.<span>  </span>I chose local machine since I am working within an Intranet.<span>  </span>The service URL shows up. I just have to click it and the URL at the top auto fills with the URL of the web service. Then you choose add reference under the right window to add the reference to your application.<span>  </span>Visual Studio will ask you if you want to put it in its own folder or not. I like to keep my things separate so I choose to keep them separate.<span>  </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">Once you do that, all you have to do is add one of code to start using it in your application:</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:12pt;color:blue;">Protected</span><span style="font-size:12pt;"> <span style="color:blue;">Sub</span> Page_Load(<span style="color:blue;">ByVal</span> sender <span style="color:blue;">As</span> <span style="color:blue;">Object</span>, <span style="color:blue;">ByVal</span> e <span style="color:blue;">As</span> System.EventArgs) <span style="color:blue;">Handles</span> <span style="color:blue;">Me</span>.Load</span><span style="font-size:12pt;"></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:12pt;color:blue;">Dim</span><span style="font-size:12pt;"> wcConvert <span style="color:blue;">As</span> <span style="color:blue;">New</span> foldername.Servicename()</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">When you create the web service it will be in a folder called App_WebReferences. Under that will be the folder name mentioned above. Under the folder is the service file. So you want to reference it by foldername.servicename().<span>  </span>That is it! You can start using it now. </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">What I did was convert it to a DataView so I could extract the data out of the dataset I needed. In order to do this, it woul dbe best to convert the dataset (web service) to a dataview. You have more options with a dataview.<span>  </span>I found out through trial and error that you cannot set up a dataview as a web service.<span>  </span>It is not a recognized XML format apparently. <span> </span>So to convert you need to add this to your code: </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:12pt;color:blue;">Imports</span><span style="font-size:12pt;"> System.Data</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:12pt;color:blue;">Imports</span><span style="font-size:12pt;"> System.Data.DataView</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:12pt;color:blue;">Dim</span><span style="font-size:12pt;"> dv <span style="color:blue;">As</span> <span style="color:blue;">New</span> DataView</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;"><span style="font-family:Times New Roman;">dv = wcConvert.functionname().Tables(0).DefaultView</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">With the dataview you can now sort (dv.sort) and select distinct values </span><span style="font-size:12pt;"><span style="font-family:Times New Roman;">DDLcontrolname.DataSource = dv.ToTable(<span style="color:blue;">True</span>, <span style="color:#a31515;">&#8220;columnName&#8221;</span>).</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;">With all the above in place you can now use the DataSource to bind to a control.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;"><span style="font-family:Times New Roman;">DDLcontrolname.DataTextField = <span style="color:#a31515;">&#8220;Name&#8221;</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;"><span style="font-family:Times New Roman;">DDLcontrolname.DataValueField = <span style="color:#a31515;">&#8220;Name&#8221;</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:12pt;"><span style="font-family:Times New Roman;">DDLcontrolname.DataBind()</span></span><span style="font-size:12pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p><span style="font-size:12pt;font-family:Arial;">That is all there is to it. Now I have to figure out how to implament caching so not to hit the web service every page refresh. Until next time, always remember, with great power comes great responsibility.</span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetteam.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetteam.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetteam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetteam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetteam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetteam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetteam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetteam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetteam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetteam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetteam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetteam.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetteam.wordpress.com&blog=4774049&post=34&subd=aspnetteam&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetteam.wordpress.com/2008/09/16/using-web-services-how-to-consume/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e7de40145b3f1678a34b54c67d2c8e44?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Frank</media:title>
		</media:content>
	</item>
	</channel>
</rss>