Adding a web service to a page

Adding a web service to a page

After selecting a web service, generating its proxy, and adding it to the Components panel, you can insert it into a page.

The illustration below shows the Components panel with the web service proxy Helloworld added. The Helloworld proxy provides one method, sayHello, which prints "Hello World."

This is a picture of the feature being described.

The following example instantiates the HelloWorld web service using ColdFusion. To learn more about creating a web services, and to see additional examples using .NET and JSP, visit the Macromedia Support Center at: www.macromedia.com/go/creating_web_services.

To add a web service to a page:

  1. In the Document window, in Code view, drag the sayHello method into the page’s HTML.

    Dreamweaver adds the method and dummy parameters to the page.

  2. Edit the inserted code with appropriate service instance names, data types, and parameter values, as required by the web service. The web service should provide descriptions of the data types and parameter values.

    In the ColdFusion example shown below, the web service is enclosed by the <cfinvoke> tags. When developing a web service in ColdFusion, use <cfinvoke> to instantiate the web service and invoke its methods.

    <html>
    <head>
    <title>Web Service</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <cfinvoke 
    webservice="http://www.mysite.com:8500:8500/helloworld/HelloWorld.cfc?wsdl"
    method="sayHello"
    returnvariable="aString">
    </cfinvoke>
    
    </body>
    </html>
    
  3. If you want to bind a return value to a visual element, switch to Design view and place a visual element on the page that can accept data binding. Then switch back to Code view and enter the appropriate code to bind the returned value to the visual element. When creating web services, refer to the technology provider’s documentation for the proper syntax with which to both instantiate the service and display the returned values to the page.

    In this example, the value returned for the variable aString is output using the ColdFusion <cfoutput> tag. This will display the sentence "The web service says: Hello world!" to the page.

    <html>
    <head>
    <title>Web Service</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <cfinvoke 
    webservice="http://www.mysite.com:8500/helloworld/HelloWorld.cfc?wsdl"
    method="sayHello"
    returnvariable="aString">
    </cfinvoke>
    
    The web service says: <cfoutput>#aString#</cfoutput>
    </body>
    </html>
    
  4. When you deploy web pages to a production server, Dreamweaver automatically copies the pages, the proxy, and any necessary libraries to the web server.


Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Defining Sources of Dynamic Content
Developing Applications Rapidly