December 3, 200619 yr I'm working with XML web services like eBay/PayPal/FedEx, etc. If I have an XML string stored in a variable within my FM script, how can I setup an HTTP post to send this request (including HTTP Header information that I need to add) and then store the response in a separate FM variable in order to parse out the data? In our current FM solution there are a few scripts that others have created in which they do exactly what I'm talking about with FedEx rates. However, they're using the External function like this: Set Variable $$RateResponse_FedEx Value: External( "JAVB-Command"; "NETT-NewForm") Set Variable $$RateResponse_FedEx Value: External( "JAVB-Command"; "NETT-SetFormData|"&$$RateRequest_FedEx) Set Variable $$RateResponse_FedEx Value: External( "JAVB-Command"; "NETT-SubmitForm|https://gateway.fedex.com:443/GatewayDC"&"|"&"30") Set Variable $$RateREsponse_FedEx Value: External("JAVB-Command"; "NETT-GetResponseData") I looked up a reference to the External function and I found that it's used for versions of FM previous to 7 to call plug-ins..?? Is there a better way to do this now? I did play with copying what they did here but I'm getting unexpected results and could use some help. Any information on this would be greatly appreciated. Thanks!
December 3, 200619 yr Author Ok, I figured out that it's using the NetTools plug-in. I installed that I went through the documentation and now I'm able to send the requests and get the response successfully. Any tips for parsing data out of an XML file and storing it in FM variables within the script so that I can then populate fields in FM with those values?
December 19, 200619 yr drew - check out this custom function we wrote for parsing xml. http://www.briandunning.com/cf/1 You may also be interested in our FedEx certified solution which allow for simple fedex shipping, rates and tracking integration with full support for thermal printers and digital scales. (we have similar tools for UPS and DHL) http://www.nrgsoft.com/products/
December 19, 200619 yr Newbies Hi, You might want to take a look at my article "HTTP POST from FileMaker" at http://fmdiff.com/fm/curlpost.html I think it covers all you want to know! Winfried
December 19, 200619 yr Author nrg software - Actually, I'm already putting your function to good use in some applications, thank you! It's difficult to use with larger XML datasets, though, like API calls from eBay and PayPal. Unless I'm missing something, I haven't been able to find an easy way to parse through an entire node of data, then move on to the next node. For instance, in datasets like <1>1> <2>2> <1>1> <2>2> I need to be able to pull all elements from the first product node, do what I need with them, and then pull all from the 2nd product node, do the same thing, etc. With your function I have to specify which occurance of the node I'd like to grab the data for. I usually don't know how many nodes are going to come back though, much less with occurance I need. Am I mis-using your tool?
December 19, 200619 yr drew - use a loop to go thru larger datasets... set variable $max = patterncount ( $xml ; "Product" ) set variable $ctr = 0 loop set variable $ctr = $ctr + 1 set variable $product = ExtractData ( $xml ; "Product" ; $ctr ) ... begin process each product... new record/request set field 1 = ExtractData ($product ; "1" ; 1 ) set field 2 = ExtractData ($product ; "2" ; 1 ) ... end process each product ... exit loop if $max = $ctr end loop Using Acme, you may hit a 64k limit on data if pulling back large sets of XML data.
Create an account or sign in to comment