Web Service in Dw.mx

Source: Internet
Author: User
Tags command line final web services zip dreamweaver wsdl
Web

Consuming Web Services in asp.net


WEB services have quickly become the most touted industry. The fact that they are based in XML and other "Internet" standards make it the ideal vehicle to send and recieve informati  On between applications. Dreamweaver MX has taken this into consideration and given your power to consume Web services in a visual environment.
When a Web service is published, it would also have a WSDL ( WEb SErvice DEfinition Language) file along with it. This is gives applications wanting to use it some meta-data concerning the service such as what are the method names  Y parameters it takes, and other useful tidbits of information. By feeding Dreamweaver The URL of "This WSDL file", you give it information it needs to create what ' s called a proxy cla  Ss. This is a. Net assembly (. dll) that hides the "intricate details involved in calling" Web service over the Intern  Et. Behind the scenes, this are done with the WSDL command line utility which is installed with the. Net SDK.
The A Web service involves finding a Web service to consume. Several web sites exists solely for this reason:
    • Sal
    • XMethods
    • Microsoft UDDI

Once you have found one of your are interested in consuming and find the "link" WSDL file.  For this tutorial, we'll be consuming the GEO Cash ATM Lookup Web service. With the This service, we can find ATM locations in any US-entering in a ZIP code.
Once you have found the service your wish to consume, you can create the proxy class for it through going to the ApplicationPanel and choosing the Componentstab.

When your click on the + icon, choose The Add using WSDL. This'll bring up the following dialog.

Enter the WSDL URL and Dreamweaver'll create two files in your site root, a. dll file which must be moved and uploaded T o The /binDirectory, 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 would reveal a tree view of available methods in the. dll.

Once all of the This is registered and you are are ready to create your Web form. Begin by creating a new. aspx file either from File > Newdialog, 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 to 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 do, your Web form should look like this:

The final step, are to add the code that would 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 are added, you can drag over the two lines from the Application > Componentstab that say:
-geocash ()
-string getatmlocations (String)
The result would 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'll have a working application. Just make this 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" comes from the Web service was a chunk of XML in the form of a string. For the purpose of the-example, we just Html encoded it so you can-the XML tags in the browser (even though the forma  Tting leaves a lot to be desired).  In a real world scenario, your would probably use the XmlDocument object to process the XML blob. The final code for this example would 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, is, to upload and test your application. Remember to also upload the Geocash.dll to your /binDirectory. Click here to a working example of the form in this tutorial.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.