﻿
{"id":787,"date":"2012-06-08T14:34:38","date_gmt":"2012-06-08T14:34:38","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=787"},"modified":"2012-06-18T21:04:01","modified_gmt":"2012-06-18T21:04:01","slug":"web-service-kullanimi","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/web-service-kullanimi\/","title":{"rendered":"Web Service Kullan\u0131m\u0131"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Bir \u00f6nceki <a href=\"http:\/\/www.gencayyildiz.com\/blog\/web-service-olusturma\/\">Web Service Olu\u015fturma<\/a>\u00a0ad\u0131ndaki yaz\u0131mda Web Service olu\u015fturma ve metodlar\u0131n\u0131 test etmeyi g\u00f6rd\u00fck.Bu yaz\u0131m\u0131zda ise yaz\u0131lm\u0131\u015f Web Service uygulamalar\u0131n\u0131 nas\u0131l kullan\u0131r\u0131z onu g\u00f6rece\u011fiz.<br \/>\n<!--more--><br \/>\nHer ne kadar kendi yazd\u0131\u011f\u0131m\u0131z Web Service \u00fczerinden \u00e7al\u0131\u015fabilirsekte ben\u00a0<a href=\"http:\/\/www.webservicex.net\/\">http:\/\/www.webservicex.net<\/a> sitesindeki Web Service lerle \u00e7al\u0131\u015faca\u011f\u0131m.<br \/>\nBu yaz\u0131da anlat\u0131lanlar\u0131n hepsi sizlerin yazd\u0131\u011f\u0131 Web Service lerde de uygulanabilir.<\/p>\n<hr \/>\n<p>\u015eimdi Web Service kullan\u0131m\u0131na de\u011finece\u011fiz.<a href=\"http:\/\/www.webservicex.net\/\">http:\/\/www.webservicex.net<\/a> sitesinden bir Web Service se\u00e7elim.Ben hava durumunu bildiren Web Service kullanmay\u0131 tercih ediyorum.<\/p>\n<p>Hava durumuyla ilgili Web Service hizmetini veren adres : http:\/\/www.webservicex.net\/globalweather.asmx<br \/>\n<span style=\"font-size: x-small;\"><em>(Bu adresi www.webservicex.net sitesi sizlere verecektir.)<\/em><\/span><\/p>\n<p>\u015eimdi Visual Studio&#8217; da bir Web ya da Windows projesi a\u00e7\u0131n.Ad\u0131 Web Service diye, illaki Web projelerinde kullanacak kanaatine varmay\u0131n.<br \/>\nBen Windows projesi a\u00e7\u0131yorum.\u0130\u00e7ine birer ComboBox ve ListBox nesnesi koyuyorum.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-788\" title=\"Web Service\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service5.png\" alt=\"\" width=\"407\" height=\"264\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service5.png 407w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service5-300x194.png 300w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/a>Projemize sa\u011f t\u0131klay\u0131p Add Service Reference diyorum.Burada dikkat edin.Add Reference diyip &#8220;ulan bu herifin anlatt\u0131\u011f\u0131 ekranla bizimki niye ayn\u0131 de\u011fil&#8221; demeyin.A\u00e7\u0131lan ekran a\u015fa\u011f\u0131daki gibi olacakt\u0131r.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-789\" title=\"Web Service\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service6.png\" alt=\"\" width=\"625\" height=\"508\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service6.png 625w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service6-300x243.png 300w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>Burada Address b\u00f6l\u00fcm\u00fcne &#8220;http:\/\/www.webservicex.net\/globalweather.asmx&#8221; linkini yazaca\u011f\u0131z.Namespace b\u00f6l\u00fcm\u00fcnde ise, kendi projemizde bu Web Service i kullanaca\u011f\u0131m\u0131z namespace ad\u0131n\u0131 verece\u011fiz.Ben namespace ad\u0131n\u0131 de\u011fi\u015ftirmiyorum.Discover ise, solution i\u00e7inde Web Service uygulaman\u0131z varsa, bu buton ile Services b\u00f6l\u00fcm\u00fcnde listeletip se\u00e7ebiliyorsunuz.<\/p>\n<p>\u015eimdi Address b\u00f6l\u00fcm\u00fcne .asmx uzant\u0131l\u0131 yolumuzu yazal\u0131m ve Go diyelim.Services b\u00f6l\u00fcm\u00fcnde listelenen Web Service i se\u00e7ip OK diyelim.<\/p>\n<p>Bu i\u015flemi yapt\u0131ktan sonra Server Explorer&#8217;da Service Referance dosyas\u0131 eklenmi\u015f.Ve bu dosyan\u0131n alt\u0131nda da ServiceReference1 ad\u0131nda bir dosya mevcut.Tabi bu isim ba\u015fta Service Reference tan\u0131mlarken verdi\u011fimiz namespace dir.<\/p>\n<p>\u00d6ncelikle Web Service namespace i i\u00e7indeki classtan nesne olu\u015fturup, bu nesne \u00fczerinden metodlar\u0131na ula\u015fal\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            ServiceReference1.GlobalWeatherSoapClient HavaDurumu = new ServiceReference1.GlobalWeatherSoapClient();\r\n            XmlDocument xml = new XmlDocument();\r\n            xml.LoadXml(HavaDurumu.GetCitiesByCountry(&quot;Turkey&quot;));\r\n            XmlNodeList Nodelar = xml.SelectNodes(&quot;NewDataSet\/Table\/City&quot;);\r\n            foreach (XmlNode item in Nodelar)\r\n            {\r\n                comboBox1.Items.Add(item.InnerText);\r\n                \/\/InnerText \u00f6zelli\u011fi ile o anki node \u0131n i\u00e7indeki yazan de\u011feri al\u0131r.\r\n            }\r\n<\/pre>\n<p>Yukar\u0131da XmlDocument s\u0131n\u0131f\u0131n\u0131 kullanmam\u0131n sebebi, Web Service sonu\u00e7 olarak XML d\u00f6nmesidir.Ee do\u011fal olarak XML s\u0131n\u0131flar\u0131yla d\u00f6nen de\u011ferleri okuyorum.<br \/>\n<span style=\"font-size: x-small;\"><em>(Not:http:\/\/www.webservicex.net\/globalweather.asmx adresinden metodlar\u0131 bir kere test edip, d\u00f6nen XML sonucuna g\u00f6re elemanlar\u0131n isimlerini bakt\u0131m.SelectNodes() metoduna rahatl\u0131kla verebildim.)<\/em><\/span><\/p>\n<p>\u015eu ana kadar ComboBox nesnemizi doldurduk.\u015eimdi de, ComboBox nesnemizin SelectedIndexChanged \u00f6zelli\u011fine gelelim.Her se\u00e7ilen \u015fehrin hava durumu bilgisini ListBox nesnemize yazd\u0131ral\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)\r\n        {\r\n            ServiceReference1.GlobalWeatherSoapClient HavaDurumu = new ServiceReference1.GlobalWeatherSoapClient();\r\n            listBox1.Items.Clear();\r\n            XmlDocument xml = new XmlDocument();\r\n            xml.LoadXml(HavaDurumu.GetWeather(comboBox1.Text,&quot;Turkey&quot;));\r\n            listBox1.Items.Add(&quot;Tarih-Zaman : &quot; + xml.SelectSingleNode(&quot;CurrentWeather\/Time&quot;).InnerText);\r\n            listBox1.Items.Add(&quot;R\u00fczgar : &quot; + xml.SelectSingleNode(&quot;CurrentWeather\/Wind&quot;).InnerText);\r\n            listBox1.Items.Add(&quot;S\u0131cakl\u0131k : &quot; + xml.SelectSingleNode(&quot;CurrentWeather\/Temperature&quot;).InnerText);\r\n        }\r\n<\/pre>\n<p>Son olarak ekran g\u00f6r\u00fcnt\u00fcs\u00fc;<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-790\" title=\"Web Service8\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service8.png\" alt=\"\" width=\"465\" height=\"340\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service8.png 465w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2012\/06\/Web-Service8-300x219.png 300w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><\/a><\/p>\n<hr \/>\n<p>Son olarak unutmaman\u0131z gereken bir nokta var.Web Service kullan\u0131rken fark\u0131na varm\u0131\u015fs\u0131n\u0131zd\u0131r ki, sizden ba\u011f\u0131ms\u0131z ki\u015fi veya ki\u015filer taraf\u0131ndan yaz\u0131lan program parcac\u0131klar\u0131 kullan\u0131yorsunuz.Kullan\u0131rken o anki projenize o Web Service i tan\u0131t\u0131yorsunuz.Yani yar\u0131n bir g\u00fcn o Web Service g\u00fcncellenirse, sizin haberiniz olmayacakt\u0131r.O halde durmadan Web Service inizi Update etmeyi unutmay\u0131n\u0131z.Bunuda Service References dosyas\u0131n\u0131n i\u00e7indeki Web Service dosyam\u0131za sa\u011f t\u0131klayarak, Update Service References demeniz yeterlidir.Web Service in yeni versiyonunu projenize set edip, sizlere gerekli yerlerde yapman\u0131z gereken ayarlamalarda haberdar edecektir.<\/p>\n<p>Bu yaz\u0131m\u0131nda sonuna gelmi\u015f bulunmaktay\u0131z.<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar..<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Bir \u00f6nceki Web Service Olu\u015fturma\u00a0ad\u0131ndaki yaz\u0131mda Web Service olu\u015fturma ve metodlar\u0131n\u0131 test etmeyi g\u00f6rd\u00fck.Bu yaz\u0131m\u0131zda ise yaz\u0131lm\u0131\u015f Web Service uygulamalar\u0131n\u0131 nas\u0131l kullan\u0131r\u0131z onu g\u00f6rece\u011fiz.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12,234],"tags":[244,752],"class_list":["post-787","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-c-sharp-c","category-xml","tag-web-service","tag-xml"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=787"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/787\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}