spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / coldfusion / 1 To page 1To page 2To page 3current pageTo page 5
[previous] [next]

Programming ColdFusion MX: Web Services

Senior Lotus Notes Developer
AMS Staffing Solutions
US-MD-Baltimore

Justtechjobs.com Post A Job | Post A Resume
Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

Registering Web Services in the ColdFusion Administrator

In the previous section, I mentioned that to call a web service, you must provide either the absolute URL to the web service's WSDL file or the name of the web service as registered in the ColdFusion Administrator. All of the examples I gave used the first method. The second method consists of registering the web service with the ColdFusion Administrator and assigning it a name. This allows you to refer to frequently accessed web services using an alias, as opposed to having to remember the (often verbose) URL to the WSDL file. It also allows you to avoid having to hardcode the URL to a web service's WSDL file in your application code. By registering the URL in the ColdFusion Administrator, you merely have to update a changed URL once in the ColdFusion Administrator, as opposed to everywhere you use it within your application code.

So, how do you go about registering web services in the ColdFusion Administrator? Well, registration happens automatically, at least partially. What I mean by this is that the first time you call a web service using any of the methods we've already discussed, the web service is automatically registered in the ColdFusion Administrator. All you have to do is go in and provide a name (alias) for the web service. To do this, follow these steps:

  1. Open the ColdFusion Administrator and click on the Web Services link under the Data & Services heading. You should see a table listing all web services that have already been registered with the server (Figure 24-4).
  2. If you want to edit the information for an existing web service, click on the Edit icon under the Actions header, or click the name of the web service under the Web Service Name heading for the appropriate web service. This will load the web services information into the Add/Edit ColdFusion Web Service form
  3. Change the name of the web service in the Web Service Name field from the URL currently displayed (it should be the URL to the WSDL file) to a more easily remembered alias. For example, in the case of the currency exchange web service from Example 24-1, an appropriate alias might be currencyExchange. Remember, the point is to register the web service with an easy-to-remember name that you can use in your application code to simplify the calling of web services.
  4. For web services that restrict access based on HTTP Basic Authentication, you can provide a username and password to pass along with the call to the web service. These values are Base64-encoded and passed as username:password in the authorization header to the target server. By specifying the username and password here, you avoid having to provide the parameters when using the cfinvoke tag to call a secured web service. For more information, see the section on "Web Services Security" at the end of the chapter.
  5. Click Update Web Service when you have finished making your changes.
  6. Figure 24-4. Registering a web service in the ColdFusion Administrator

     

Using the steps provided, it's also possible to register a new web service that hasn't yet been called from your ColdFusion server.

Once you have created an alias for your registered web service, you can use the alias instead of the full URL to the WSDL file whenever you need to consume the web service. Thus, to invoke the currency exchange web service (assuming you registered its alias as currencyExchange), you would use the following:

<cfinvoke
  webservice="currencyExchange"          
  method="getRate"
  returnvariable="aRate">
    <cfinvokeargument name="country1" value="united states"/>
    <cfinvokeargument name="country2" value="euro"/>
</cfinvoke>
   
<cfoutput>
1 USD = #aRate# Euros
</cfoutput>

home / programming / coldfusion / 1 To page 1To page 2To page 3current pageTo page 5
[previous] [next]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

Created: March 27, 2003
Revised: Sept 1, 2003

URL: http://webreference.com/programming/coldfusion/1