Web service in DW.mx

web

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.
 

时间: 2024-08-07 21:42:20

Web service in DW.mx的相关文章

使用 JSP 集成 Amazon Web Service

在本系列文章的 第 1 部分 中,我们介绍了如何使用 Notes/Domino 6 来集成 Amazon Web Service.我 们确信很多读者很想了解如何使用 J2EE 来创建类似的应用程序,因为 IBM 已经从技术方面做出了很多努力 .因此,在本文中,我们将介绍如何使用 J2EE 来重新创建在第一篇文章中构建的 Notes 应用程序,同时还 将介绍这种技术与 Domino 的不同.本文的目的是为 Domino 开发人员简要介绍如何可以使用 J2EE 采用一种 不同的方法来开发一个类似的

在WebSphere Portlet Factory中调用Web Service

通过 WebSphere Portlet Factory(WPF),开发者非常方便实现 Web Service 和 Portlets 的通信.开发者无需花费大量的时间去学习 SOAP,WSDL,XML schema(xsd) 等 Web Service 技术,使用 WPF 即可开发出健壮.功能强大的 Web Service 和实现对各种风格的 Web Service 的调用.WPF 隐藏了 Web Service 的内部实现细节,通过 WPF 的丰富的构建器自动生成 Web Service 和实

[Java] 利用Axis库调用C#的Web Service

[Java] 利用Axis库调用C#的Web Service 编写者 日期 关键词 郑昀@ultrapower 2005-8-2 Java Web Service Axis C#   概述 试图从Java调用C#编写的Web Service,借用了王咏刚的wsCaller源代码中DynamicInvoker类. 开始不清楚DynamicInvoker类的portName的含义,望文生义,以为是8080之类的端口号,实际上是下面wsdl中的wsdl:port 节点的"name"属性值&q

JavaScript跨域请求RESTful Web Service

当我们用js请求RESTful Web Service的时候,通常会出现跨域无法访问的问题,也就是无法正常得到我们要的值.jsonp是个解决问题的方法.但是,我们希望访问RESTful Web Service就像一般的ajax方法一样,不用每个都去搞一个jsonp和callback.这就需要我们在服务端进行一些设置,下面我用一个简单的 Filter来进行说明,其他比较复杂的情况根据自己的需求进行改动. import java.io.IOException; import javax.servle

手把手教你实现、部署和调用Web Service

手把手教你实现.部署和调用Web Service

教程/dreamweaver/提高 体验DW MX 2004 CSS新功能

css|dreamweaver|教程  CSS是制作网页效果必不可少的东西,字体的颜色定义.表格的样式定义.图片的特效等等都少不了它.但在Dreamweaver的早期版本中CSS的编辑功能并不是很强大,有时候不得不借助一些类似于TopStyle的第三方工具来完成CSS的编写. 现在有了Dreamweaver MX 2004(简称DW MX 2004),情况就完全不同了! 首先我们给页面链接一个已经编写好的CSS文件,这里的操作与老版本Dreamweaver的方法是相同的(图1). 链接好后,和老

XML Web Service 安全性

web|xml|安全|安全性     当我们谈及 XML Web Service 时,人们最关心的问题就是其安全性. XML Web Service 安全吗? 鉴于安全性涉及诸多方面(例如身份验证和授权.数据隐私和完整性等),以及 SOAP 规范中根本没有提及安全性这一事实,我们不难理解人们为什么认为答案是否定的.但是,请不要低估了 Microsoft? XML Web Service.如今,您可以采取许多措施来创建安全的 XML Web Service. 要解决 XML Web Service

教你学会XML Web Service 的基础

web|xml 什么是 XML Web Service? XML Web Service 是在 Internet 上进行分布式计算的基本构造块.开放的标准以及对用户和应用程序之间的通信和协作的关注产生了这样一种环境,在这种环境下,XML Web Service 成为应用程序集成的平台.应用程序是通过使用多个不同来源的 XML Web Service 构造而成的,这些服务相互协同工作,而不管它们位于何处或者如何实现. 有多少个构建 XML Web Service 的公司,就可能有多少种 XML W

.NET调PHP Web Service的典型例子

最近一个项目由"WinForm直接访问DB2"移植到"WinForm通过PHP Web Service来访问DB2". (优点是php可以架在Linux上,而Linux是免费的) 这个命题的难点不是访问DB2,而是.NET调用PHP的Web Service.对于我这个长期作.NET,之前一直以为只有.NET才可以做Web Service--的人来说,真是有点强"聪"所难了. 但是问题还是要解决的,期限就摆在眼前呢.经过一番调查,终于有了眉目,现在