FileMaker – Best way to use SOAP services

Now and then you have to implement some SOAP web-services into your FileMaker solution. FileMaker does not have a built in Web Service Wizard or SOAP client support. This article will go through the method to implement this the most effective way I know about.

The big advantage of SOAP API’s

There is a lot of different API-flavours out there. Different difficulty levels to implement, but all have this common move that they accept connections, sending a request, and give responses in one form or another.  The formatting of the request and the format of the returned data is described in the API documentation. However, in a SOAP API, we use a WSDL file that is used both on the server side and the client side, and at the same time acts as an important documentation document makes the security of implementing the API that each message is formatted correctly and contain all the required elements in both directions. One cannot change the requirements or the contents of the data-elements on the server side without also changing the WSDL, so in this way, there is a guarantee that the documentation is up-to-date all the time.

Many development tools have built in SOAP Client wizards that help you implement the service, so it is not very difficult in most cases.

How do we do it in FileMaker?

In this tutorial, we will implement an online barcode generator Webservice into our FileMaker application. This can be useful for printing labels and so on.

The demo FileMaker database is available at the bottom of the article.

We depend upon one external plugin to do the HTTP(S) access necessary. SOAP services use the POST protocol, so any insert from URL calls are off the board for this implementation. I will use the TROI URL plugin for this as my recommendation. The version 4.1 of this plugin is a minimum.

There is also a number of tools needed in this tutorial. Some are free, and some at fairly low cost. Here is the list.

  • PAW (MacOS) – Utility to do web-service testing on MacOS. It cost about 49 USD. This software is not used in this particular demonstration but is a very good tool if your service does not behave as expected. You can test the service, and see what responses you get.
  • Any XML or ASCII file editor to edit XML. I am using Oxygen XML editor or BBEdit for that, but any clean text editor will do.
  • Online WSDL analyzer, at www.wsdl-analyzer.com. Used for documentation and generating request templates for our service implementation.
  • To do an import of SOAP service requests, we do need TROI FILE plugin to save the content of the SOAP result to a temporary file.
  • Additionally, the site xmlbeautifier.com is a good tool, when you cut & paste XML responses from the FileMaker data viewer. The XML often comes in one long line and is not easily readable. copy and paste it into this site, and hit “beautify” does the trick.

The WEB service documentation

Most Web services have a comprehensive documentation. Sometimes, it is easy to get lost in the documentation provided as it is so comprehensive and yet fails to provide the simplicity we need to get an overview. The most important piece of documentation we need is the WSDL file itself. This contains almost everything you need to set up the service calls. As the WSDL file is a bit complicated, we use an online tool called WSDL-analyzer that provide us with that simplicity we need.

In order to use it, we will first download the WSDL file for the web service. The WSDL URL is provided from the provider of the service. In this example, it is :

http://www.webservicex.net/genericbarcode.asmx?WSDL

Open the link, and save the file. Rename extension to be “.wsdl”. Go to WSDL-analyzer, and upload the WSDL file. Sometimes, it does not open after upload, but a refresh works well in most cases.

Scroll down to the section of “PortType” where you have all the operations available for that Webservice. Click on the actual “operation” in the left column of the table.

Then you will see a page containing the request template to use.

Copy and paste the Request template into a text editor or an XML-editor, to edit the template. We want to create a custom function that does the whole soap request and return the actual XML response we get from the service. In this way, we can reuse the code in many places, and easily copy the function between several FileMaker databases.

The request template:

First, we must get rid of double quotes – if any. We replace them with single quotes so we can encapsulate the whole block in double quotes in the custom function. There aren’t any in this example, so we go on.

We need to decide which optional parameters to use. Those we don’t use, we cut out.

Then we add placeholder text for the parameters we do want to use. The parameters we want to have a fixed value, we just type that.  The placeholders will be replaced in our custom function with the parameter values of our custom function.

Our Custom Function.

In FileMaker, we open our solution, and go to Custom Functions, and create a new. We can use this as a template for it for later SOAP services, but here is the one I have created for this service:

Soap_BarCode ( vUrl ; Height ; Width ; Angle ; Ratio ; Module ; LeftPos ; TopPos ; BarColor ; BGColor ; FontSize ; barcodeOption ; barcodeType ; showTextPosition ; BarCodeText )

A second useful Custom Function – to extract XML tags from the response.

ExtractXMLData ( XML ; Attribute ; Instance )

 

The Script

I created a table for use with this test application. It basically contains a container field to show the image and each parameter to the service. The Table def looks like this.

A little script now to call the service:

 

The result:

The practical use of this particular Webservice

In this example, I have populated all the parameters in this table, just to be able to experiment with the different parameters. However, in a practical implementation, one would just use the container field on the record containing the data this barcode is about, to example a product. Then, in the call to our custom function, just apply the values needed as constants, except for the barcode text of course. The call to this function could be in a trigger script on the barcode-text field, where it is called each time the barcode text is changed.

Download the example file:

PS – You need to install the TROI URL plugin in order to get this demo to work.

SOAP-Barcode-Example.fmp12

How to quickly create html form-fields using BBEdit’s GREP search and replace function

Creating HTML form field from a list of database fields can be a tedious task, with a lot of exact matching of names both in the creation of the form fields, ajax handlers in PHP and javascript code to update.

Fortunately, BBEdit has a GREP search and replace function that helps us do the task semi-automatically. Continue reading

Using regular expression to merge database content into Rich Text format (RTF) template documents

As Rich Text Format (RTF) documents really are text-based documents, it sounds like a simple task to use it as a base for creating merge documents from database applications. The inserted tags in such a document can easily be replaced with contents of database fields to produce merged documents ready to be opened in Microsoft Word.

Practical experience with such a solution is, however not that straight forward. Why is that? – Microsoft Word sometimes injects formatting codes in between the tags to accomplish word-splitting proposals or whatever. Those formatting codes cannot be seen in Microsoft Word, but in a plain text editor, you will see why a substitution of the tag sometimes fails. To example, such plain merge tag like this:

Becomes like this:

A simple replace string to replace the tag with a database content field, will then fail. The solution to this, is to use regular expression matching to find and replace the tags with the database content. Continue reading

Redmine Issue tracking Versus GitHub & Importing stuff into Redmine

As a number of issues grow for a given project, the flat issue tracking concept in GitHub can be hard to use. There are other systems that do this better, like Redmine that I have switched to.

The problem then, is: How do I get all the GitHub issues imported into Redmine? – If you have several hundreds of issues in GitHub, and a function to import this is crucial to do a successful switch. Continue reading

FormulaCalculator Goes Open Source

The FormulaCalculator Project for MacOSX developed in XCode, Cocoa and Objective C is now available as an open source project. It was developed as an desktop calculator to include more shopisticated functions and better user interface for those who do advanced math, but also for regular users.

As the term Formula Calculator says, this is more a kind of formula interpreter type of Calculator, but at the same time, it inherits the properties of an ordinary calc using the buttons to calculate.

The user has far more control over the calculations being able to see the formula as it is keyed in – and the ability to correct mistakes.

The calculator contains a huge formula collection defined as functions. This makes it simple to do conventional calculations that often need an complex formula.

The plan was to include an formula editor to let the user extend the formula library on his own. It has not been time to work more on this project recently, but it might be a new feature some time in the future.

In the meantime, if someone wants to dewnload and tweak the code to include more functions needed, then it is just to head over to Github and download the source.

The project is available at: github.com/olekrisek/formcalc-osx

Where is my BuddyPress Links admin panel?

Update: The plugin author of “BuddyPress Links” has now released a new version (0.7.2) that addresses this problem. For users with earlier version the above version should be installed. The remaining of the article was wrote for the previous version (0.7.1).
——-
You might have installed the buddypress-links plugin to your buddypress site, and discover there is no sign of the admin panel for the plugin. Thats right, for a new fresh install of WordPress 3.5 Multisite, BuddyPress, and BuddyPress links plugin, there is no admin panel for BudyPress links. Read this article to see how to solve this. Continue reading