FileMaker Extra: Write Your Own Web Services

 <  Day Day Up  >  

We generally think of Web services as being something that someone else has, and that we want access to. But Web services have many other uses as well. They can provide a powerful way to extend the capabilities of your FileMaker application.

For example, suppose you needed to compute a Fourier transform, based on some measured signal data. FileMaker has no built-in facility for such analysis ”computing the transform requires complex mathematics. (Well, with enough diligence, you might be able to write a FileMaker script to perform a Discrete Fourier Transform, but its cousin the Fast Fourier Transform requires mathematical operations FileMaker can't perform.)

NOTE

Don't worry if Fourier transforms don't ring a bell; its just a data example. A Fourier transform is an advanced mathematical technique for taking a complex signal, such as a sound or radio wave, and decomposing it into a series of simpler signals.


FileMaker already provides a number of extension mechanisms to developers. Many problems can be solved with a custom function. Those that can't may be addressed by a plug-in already in existence.

For more details about installing and using FileMaker plug-ins, see "Plug-ins," p. 789 .


Web services provide another way to extend FileMaker's capabilities. They are, in our view, easier to write than plugins, which require knowledge of a low-level programming language such as C++, and knowledge of how to program in each specific client environment supported by FileMaker 7, namely Windows and the Mac OS. Web services, by contrast, can be written in the "lighter-weight" scripting languages, which we feel are easier to learn, and because they execute in a server environment, they don't require that you have any knowledge of how to program specifically for the Mac or Windows.

Of course, this points up one of the hurdles involved in writing your own Web service: You still have to know how. Web services can be written in a wide variety of programming languages, such as PHP, Perl, JSP, ASP, Visual Basic, Tango, Lasso, or any of many other "Web scripting languages," not to mention hard- core languages such as Java, C, or C++. There's literally no limit to the kinds of work you can perform with Web services written in these languages. The only catch is, again, you have to know how.

Of the languages discussed, we feel the "Web scripting" languages are probably the most approachable. PHP is a superb general-purpose Web scripting language. JSP has a Java base, whereas ASP and Visual Basic are particular to a Windows server environment. Tango and Lasso were once exclusively FileMaker-aware Web tools, but have since grown into more general-purpose languages. All these languages presume some familiarity with the fundamentals of computer programming, and familiarity with the specific language in question.

Let's return again to the hypothetical example. Let's say you're importing signal data from an electronic instrument of some kind. You have the raw data, and you want to compute a Discrete Fourier Transform of the samples. Our strategy for doing this is twofold: First we write a Web service capable of doing the math, then we call that Web service from FileMaker, hand it our data, and get our results back in return.

In a book of this kind, we can't explain in detail how to write the kind of Web service that would do this. Conceptually, if you know a language like PHP, you can write a PHP program, designed to be accessed over the Web, which expects to receive a vector of numbers in the request. You would call the Web service via a URL, which might look something like this:

 

 http://webservices.my-company.net/DFT.php?samples="1.0, .45, 3.2, -.23, 1.76, 1.55, 2.01, graphics/ccc.gif 1.23, .34, -.78, -.64, -.09" 

The "samples" represent the actual data you are sending to the Web service for processing. You would compose the URL dynamically in FileMaker, much as we demonstrated for the Amazon example earlier in this chapter. The URL accesses the Web server at webservices.my-company.com , requests access to the Discrete Fourier Transform program, and passes the DFT program a series of sample values. The DFT program processes the information, and returns some information. For the purposes of getting the resulting data back into FileMaker, we want to work through the FileMaker XML Import feature, so the DFT program should output XML of some sort ”either straight FMPXML that we can import back into FileMaker, or some other XML flavor that we can transform with a stylesheet.

So what's DFT.php? Well, it would be a program, written in the PHP language, that knows how to compute a Discrete Fourier Transform from a vector of numbers, and output the results in XML. You might choose to write the program in straight PHP. For more advanced math, though, such as the more complex Fast Fourier Transform, you might choose to use PHP to call a code library on the Web server computer, which would perform the complex math in a very fast language such as C.

The one downside to using Web services in this way (besides the need to learn one or more additional languages) is that the Web service functionality doesn't really live "in FileMaker"; it lives on a server someplace, so if you are creating standalone FileMaker applications that are meant to work in a single- user , non-hosted environment, or possibly an environment with no network or Internet connection, then home-brew Web services are probably not the way to go.

There are relatively few limits to the kinds of programming tasks you can accomplish "in FileMaker," just by hooking FileMaker up to the appropriately-written Web service. Of course, those services are not trivial to produce in practice. But if you have the knowledge to do so (or access to someone with such knowledge), the potential uses are almost limitless.

To recap, Web services can provide a way to extend the capabilities of FileMaker. The range of possible functionality is much wider than that afforded by custom functions, and programming Web services is, in general, easier than programming FileMaker plug-ins (which requires writing platform-specific compiled code).

 <  Day Day Up  >  


QUE CORPORATION - Using Filemaker pro X
QUE CORPORATION - Using Filemaker pro X
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 494

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net