国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

Web service in DW.mx

2024-07-21 02:22:07
字體:
供稿:網(wǎng)友

consuming web services in asp.net


web services have quickly become the most touted industry buzzword.  the fact that they are based on xml and other "internet" standards make it the ideal vehicle to send and recieve information between applications.  dreamweaver mx has taken this into consideration and given you the power to consume web services in a visual environment.
when a web service is published, it will also have a wsdl (web service definition language) file along with it.  this gives applications wanting to use it some meta-data concerning the service such as what are the method names, how many parameters it takes, and other useful tidbits of information.  by feeding dreamweaver the url of this wsdl file, you give it the information it needs to create what's called a proxy class.  this is a .net assembly (.dll) that hides all of the intricate details involved in calling the web service over the internet.  behind the scenes, this is done with the wsdl command line utility that is installed with the .net sdk.
the first step in consuming a web service involves finding a web service to consume.  several web sites exists solely for this reason:
  • sal central
  • xmethods
  • microsoft uddi

once you have found one you are interested in consuming, find the link the wsdl file.  for this tutorial, we will be consuming the geo cash atm lookup web service.  with this service, we can find atm locations in any us city by entering in a zip code.
once you have found the service you wish to consume, you can create the proxy class for it by going to the application panel and choosing the components tab.

when you click on the + icon, choose add using wsdl.  this will bring up the following dialog.

enter the wsdl url and dreamweaver will create two files in your site root, a .dll file which must be moved and uploaded to the /bin directory, and a .cs file with the source for the .dll in case you want to take a peek below the hood.  another look at the components panel will reveal a tree view of available methods in the .dll.

once all of this is registered, you are ready to create your web form.  begin by creating a new .aspx file either from file > new dialog, or right clicking in the site window and choosing new file.  
create the web form by following these steps:
  1. add a form from the form object panel
  2. enter code view and change the opening form tag to look like this:
    <form runat="server">
  3. from the asp.net object panel, insert a textbox with the id of zip.
  4. next, insert an asp.net button with the id of submit
  5. after adding the button id, go the event > onclick option in the tag editor and add the text "submit_click"
  6. add a simple asp.net label with the id result

once all of this has been done, your web form should look like this:

the final step, is to add the code that will process the geocash service.  begin by adding this code to the top of the page.
<script language="c#" runat="server">
void submit_click(object ob, eventargs ev)
{

}
</script>
once that is added, you can drag over the two lines from the application > components tab that say:
-geocash()
-string getatmlocations(string)
the result will look like this.
<script language="c#" runat="server">
void submit_click(object ob, eventargs ev)
{
geocash ageocash = new geocash();
string astring = ageocash.getatmlocations(/*string*/enter_value_here);
}
</script>
one more small modification, and you will have a working application.  just make these small changes to the code.
  • replace /*string*/enter_value_here with zip.text
  • add this line right before the closing }
    result.text = server.htmlencode(astring);

the result that comes from the web service is a chunk of xml in the form of a string.  for the purpose of this example, we just html encoded it so you can see the xml tags in the browser (even though the formatting leaves a lot to be desired).  in a real world scenario, you would probably use the xmldocument object to process the xml blob.  the final code for this example will look like this:
<script language="c#" runat="server">
void submit_click(object ob, eventargs ev)
{
geocash ageocash = new geocash();
string astring = ageocash.getatmlocations(zip.text);
result.text = server.htmlencode(astring);
}
</script>
the only thing that is left is to upload and test your application.  remember to also upload the geocash.dll to your /bin directory.  click here to see a working example of the form in this tutorial.
 國內(nèi)最大的酷站演示中心!
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 惠安县| 阿克陶县| 南溪县| 柳河县| 西峡县| 湖南省| 惠安县| 扎囊县| 隆昌县| 巫溪县| 西盟| 长春市| 墨竹工卡县| 锡林郭勒盟| 竹北市| 资溪县| 花莲市| 福鼎市| 安仁县| 涿鹿县| 甘孜| 临猗县| 正安县| 增城市| 阳曲县| 阿图什市| 天峨县| 吴旗县| 牙克石市| 梁平县| 肇东市| 德清县| 隆昌县| 铜川市| 嘉峪关市| 卢湾区| 长垣县| 济阳县| 北碚区| 南丰县| 剑川县|