Steve McKean Web Programming Pages: Introduction to Web Programming - Web services

Session 15: Web services


LINKS:: JOURNALS| UDDI | WC3 |
web services, 743-770
      accessing behind firewall, 750
      architecture, components of, 744
      ColdFusion MX, 753
      consuming, 745-760
            complex datatypes, 754-760
            generating CFML manually, 749
            generating CFML with Dreamweaver MX, 746
            timeout value, 910
      converting CFCs to, 760
      defining complex datatypes, 932
      instantiating, 909
      producing, 760
      registering in ColdFusion Administrator, 751
      security, 767-770
            via built-in security framework, 768-770
            via HTTP Basic Authentication, 767
Web Services Description Language (see WSDL)

Web services

Web services is the last option for re-using code to be discussed in this course. In addition to re-using code, web services also contribute to making web processing more efficient by distributed processing because they permit a number of applications on different locations to share software as well as computing facilities.

The technology can best be explained by Figure 4 . Assume a number, k , of end users (clients) requesting applications from a set of  m servers. Some of the applications require, however, special components residing in a second set of n servers which are providing the result of their components as Web Services . The services are, like the applications of the first set of servers, offered on the nett and can be integrated in the different applications just as if they were local components. To the end users, the applications they request will appear as if the applications are executed by the application servers. In the figure, it is, as an example, assumed that end user 1 requests both application 1 and m , while end user k only request application m . To deliver, application 1 needs both web services 1 and n , while application m only needs web service n to deliver. Of course, most applications do not at all require the services of another server.

Web service is a concept which has entered the web arena in the last few years. Even though the technology is supported by major vendors and seems to have a potential for contributing to remote, distributed processing on the net,.it is still controversial .

It uses a set of standards/technologies including:

  • TCP/IP
  • HTTP,
  • XML,
  • Universal Description, Discovery and Integration (UDDI).
  • Web Service Description Language (WSDL)
  • Simple Object Access Protocol (SOAP),

The Web service is an open source technology supported by many important actors in the web domain. A Web service is said to be created by its developers, and consumed by their users. ColdFusion MX supports creation as well as consumption of Web services by the CFMX Component technology discussed in a previous session. Journals for web services have been establish for developers and consumers to maintain their knowledge about the state of the art.

In this session we review UDDI , WSDL and SOAP , and discuss how you create and consume a web service.

Universal Description, Discovery, and Integration

The first condition for being able to consume a web service is to know of its existence. An UDDI registry is a facility established for locating sources of web services. It can be a local enterprise restriucted or an open, public registry. Market actors as IBM and Microsoft are running global UDDI s. A popular UDDI is XMethods to which you can get your own web service registered. You can also publish your web services in your own UDDI . CFMX does not contain any special features for establishing an UDDI , but the design and development of an UDDI can be done by means of CFMX ..

Web Service Description Language

WSDL is an XML format for describing net services. Description of web services are therefore standardized in an XML based document prepared by the Web Service Description Language , WSDL . The WSDL describes the requirements for consuming a web service. The CFMX developer does not need to be concerned about writing the WSDL for the component he/she develops, it is done automatically by CFMX . As we shall see later in this session, likewise to view the WSDL of an existing component does not require more than typing the URL of the component with a short extention. A visit to W3C gives useful and official information on web services.

Simple Object Access Protocol

SOAP provides an XML messaging framework used by web services. For a CFMX developer, it is not necessary to learn the SOAP technology, or be at all concerned about it, since it is handled automatically by the CFMX web service technology .

Web services creation and consumption in CFMX

Consider the following scenario. A number of developers are working on different web applications within a world wide organization. Applications need all accesscode authorization, and the codes must be unique for each user independent of application. A Web service providing unique accesscodes can be the solution.

A web service example

We use the component developed above to serve in the scenario outlined above. A few changes have to be done. In CFMX , Web services are created using components . Each CFFUNCTION tag in a Web service component needs an attribute ACCESS="remote" and an attribute RETURNTYPE="string|number|boolean| etc" . Except for these to conditions, the Web service component looks and works as an ordinary component and may be considered as an "external" component from a CFMX developer's point of view. The following example is therefore quite similar to the example discussed discussed above in connection with components.

The use of a Web service is referred to as service consumption . An application which need the support from a Web service must have a way to call on the service. The application server can, just as if it should apply one of its own components, use the CFINVOKE tag. However, in the case of calling a Web service component , the tag must contain an attribute WEBSERVICE="<name>" . The value <name> is either the URL of the WSDL of the service, or an alias name registered by the CFMX Administrator of the consuming server. The call for the service is embedded in a template of the consuming application.

The calling is illustrated by access_no.cfm template, which requests a unique accesscode, and displays the received code for the client who wants to see the example. The template is very similar to that used in the component example. The only difference is other attributes in the CFINVOKE tag. Note that WEBSERVICE and RETURNVARIABLE are required attributes.

The webservice is supposed to be registered by the CFMX Administrator of the consuming server, and named (alias) access_no .

  1. <!--- access_no.cfm --->
  2. <cfinvoke webservice="access_no" method="Main" returnvariable="access_no"></cfinvoke>
  3. <center>
  4. < h2><font color="#0000FF">A vacant access number is:</font></h2>
  5. < cfoutput>
  6. #access_no#
  7. </cfoutput>
  8. </center>

In the same way as local components, web services can be called in alternative ways, e.g. by means of the tag CFOBJECT , the function createobject() ,etc.

The Web service known to the application server as access_no differs from the local component, access_no.cfc, ,introduced above only by the the function tag remotely called. The remaining functions are called within the component and need no changes.

  1. <!--- Webservice: access_ no ---->
  2. <cfcomponent hint="This component returns an unused accessnumber in the interval 10000 - 99999">
  3. <!--- main() --->
  4. <cffunction hint="Controls the process" name="main" access="remote" returntype="any" >
  5. ...
  6. ...

About the implementation of the example

To demonstrate a webservice, we need a client and 2 servers , an application server consuming the webservice of the second. . In the example, both roles are played by the same server. The consuming part is issuing an URL call, a loop call , on the net to the same server from which the call originates. This is just an analogy to using the localhost for testing an application.

Exercises

a. You are encouraged to copy and try out the examples for yourself. An challenging task will be to work out how a component can be called by means of the CFOBJECT tag.

b. Review your project templates and identify code sequences which you have used repetitively. Transform these sequences to Custom Tags , and evaluate what you gained in your project, and if you can benefit from your Custom Tags in future applications.

c. The experts recommend that you code your UDF based on tags . Re-write the UDF script-based function sum_integers(number) as a tag-based UDF and test it.

d. RBB discusses Function Libraries in Chapter 20. Read the chapter carefully. He refers to an open source repository named the Common Function Library Project . Import the library and see if you find any interesting and useful functions for your project in the library.

e. There are many ways of constructing and using components. RBB discusses some of them in Chapter 22. Components build on UDF is discussed in detail in RBB Chapter 20. You are recommended to read this chapter, and try pout some of the suggestions.

f. Consider how you would reorganize your own project if you should have implemented it by means of components.

e. You are welcome to study the wsdl of as well as and invoke the webservice: http://nordbotten.ifi.uib.no/webservices/access_webservice.cfc?wsdl called from an application on your own computer.

You are reminded to turn to the Assignment section, complete and submit your final project report. You are required to both submit your final progress report and pass the Test within the deadlines specified in the Calendar to qualify for taking the written exam.

Link to the session assignment.

Link to the session examples.

Link to the session test.

 

 

 

Other information:

Articles - Macromedia

 

 

 

 

 

 

 


[top]

Web services

HOME- INDEX - HTM
oreilly EX. 3 -10
OREILLY EX. 11 - 17
OREILLY EX. 18 - 28
OREILLY PAGE INDEX
WACK
WACK EX. 1 - 14
WACK EX. 15 - 25
WACK EX. 26 - 36
WACK PAGE INDEX

 

ADOBE - COLDFUSION TAG REFERENCE
FUNCTION REFERENCE
 
MACROMEDIA LIVEDOCS
 
macromedia help

 

Course Project

MY LINKS- RESOURCES

Steve McKean
UH-Email

CT LOGIN

CT FORUM CF
user - enter

MACROMEDIA FORUM
user - enter

Course Project MY LINKS- RESOURCES Steve McKean UH-Email
 
ADOBE - COLDFUSION TAG REFERENCE
FUNCTION REFERENCE
 
6
7

 

Course Project

MY LINKS- RESOURCES

Steve McKean
UH-Email

CT LOGIN

CT FORUM CF
user - enter

MACROMEDIA FORUM user - enter

 
TWW

O'Reilly Book Site

Read Me

 

CFMX HISTORY RESOURCES
OBJECTIVES

1.-Introduction to web programming
2. Implementation tool: CFML

Application
Examples

3.- Market research application
4.- Using databases
5.- Online experiments
6.- Search engines
7.-e-learning
8.- e-shops
9.- Agents

Implementation aspects:

10.-Data exchange
11. -Regular expressions
12. -Re-using code
13. -Distributed processing
14 .- CF components
15. -Web services

Course project