Friday, December 4, 2009

Fedex Web Services + createObject("webservice") == Migraine

A very long time ago, I wrote an entry on my novice struggles using the Fedex web services with createObject(). Though the entry shows I still had a lot to learn about web services, I still get occasional questions about it. In particular, about working with the Fedex web services and createObject(). So I will offer this advice to anyone looking to do the same - don't.

While ColdFusion definitely simplifies the process of working with web services, it is also not the best tool for every web service. Especially the more complex ones. If you have ever tried using the FedEx web services with createObject("webservice"), you know how painful it can be. They are extremely complex and deeply nested. So unless you miraculously hit on the right code the first time around, you are likely to waste a LOT of time trying to troubleshoot cryptic Axis error messages .. and the time you spend will not be fun.

So my recommendation is to try using SOAP + CFHTTP instead. The Fedex WSDL developer files include working SOAP samples. They will get you up and running much faster than trying to translate the java examples into CF code. An old entry on Russ Michaels blog has some good tips on working with SOAP. There is also a current project using the SOAP approach with the Fedex Rates Web Service, under the project name CFFedexRates. You could easily use it as a base for some of the other web services.

Take my word for it, you will be glad you did.

Update December 9, 2009:
For a version of CFFedexRates that is compatible with the Rate Service v7, see issue #2 http://code.google.com/p/cffedexrates/issues/detail?id=2


Update January 21, 2010:
The featured downloads section was updated to include a version compatible with Rate Service v7.

Update May 4, 2010:
For a version of CFFedexRates that is compatible with the Rate Service v8, see issue #4 http://code.google.com/p/cffedexrates/issues/detail?id=4

5 comments:

Matthew Williams December 7, 2009 at 10:17 AM  

RIAforge.com also has a FedEx rate example should anyone be looking for one (note, it's not mine... I just choose to use it).

cfSearching December 7, 2009 at 10:30 AM  

@Matthew,

Thanks for mentioning another fedex example. The more the better. Would you mind posting a link? My brain must be broken, because I did not see any Fedex projects when last I looked ;-)

Cheers
-Leigh

Roy Martin December 9, 2009 at 2:41 PM  

Couldn't have timed this post any better. We were looking for alternatives because all of the existing packages that we could find used the v3-v5. We recently received a client request to update to use a feature introduced in v7. If you could point us to, or could provide a working example submission using the v7 protocol that would be greatly appreciated. We all have migraines over here after the repeat bashing of heads against desks as we got the same response back no matter which method we seem to try (cfinvoke, createobject, cfhttp).

Thanks,
Roy

cfSearching December 9, 2009 at 6:26 PM  

Hi @Roy,

Which one, the Rate Service?

-Leigh

cfSearching December 9, 2009 at 8:03 PM  

@Roy,

I made some minor changes to the CFFedexRates cfc (which uses SOAP+CFHTTP), so it works with v7. I uploaded a copy to Issues. (Note: CFFedexRates is not my project)

http://code.google.com/p/cffedexrates/issues/detail?id=2


HTH
-Leigh

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Header image adapted from atomicjeep