Integrating your FileMaker database with a third party system can be complex and painful. However if they publish a WSDL (Web Services Description Language) then things become a lot easier. The integration is basically a two way conversation using XML, and is made very easy with the Web Services Plugin from Beezwax.
The Web Services Plugin takes the XML definition from the publisher and creates external functions within the plugin that can be called from FileMaker like any other call.
This means that sending data to the third party is as easy as filling in a standard FileMaker function.
The complicated bit is that what comes back is still XML.
To deal with this you have two options.
1. Export the data as a text file and reimport it using a XSLT.
2. Look into the XML and extract the required data using a calculation or script.
Option 2 is my preferred method as XSLT are very complicated and you need one for every different call to the Web Service.
To do this I wrote two custom functions to extract data from the XML
First I used this function called XMLTags( XML ) to get a list of all the different tags within the XML
p1 = Position ( XML ; “<” ; 1 ; 1 );p2 = Position ( XML ; “>” ; 1 ; 1 );
Tag = Middle ( XML ; p1+1 ; p2 – p1-1 )
Case(PatternCount ( XML ; “<” & Tag & “>” ) = 0 ; “” ; PatternCount ( XML ; “<” & Tag & “>” ) > 0; “<” & Tag & “>¶” & XMLTags( Substitute ( XML ; [ “<” & Tag & “>” ; “” ] ; [ “</” & Tag & “>” ; “” ] ))))
and then once I knew the name of the tag I wanted, I could extract the data using ExtractXML( XML ; Tag )
data = XML;
fulltag = “<” & Tag & “>”;
count = PatternCount ( data ; fulltag );
taglength = Length( fulltag ) ;
Start = Position ( data ; fulltag ; 1 ; 1 ) ;
End = Position ( data ; “</” & tag & “>” ; 1 ; 1 )
count = 0 ; “” ;
count = 1 ; Middle ( data ; Start + taglength ; End – Start – taglength ) ;
count > 1 ; Middle ( data ; Start + taglength ; End – Start – taglength ) & “¶” & ExtractXML( Right( data ; Length(data) – End ) ; Tag )
This returns a delimited list of all the data inside the tag specified and is good for extracting a few pieces of data from the result when posting information; i.e uploading products and getting the third party record ID back.
As all WSDLs are different this plugin takes the graft out of generating XML calls as it does it all for you.
As the XML returned for things like getting orders and the line items is very complex I will cover this later.