Wednesday, September 26, 2012

Consuming the Soliditet webservice in Coldfusion 9

I recently ran into problems consuming a webservice which gives company ratings for Swedish companies provided by Soliditet.

I was aware of the limitations of cfinvoke and CreateObject when it comes to certain SOAP-services, so my approach was to build the request manually as xml and use <cfhttp> to post it.

If I searched and got no hits: No problem. I received a perfect xml-doc in return stating "No hits". The same with "Too many hits". But when I got a response which should return between 1 and 50 hits, I got the dreaded:


struct
Charset
[empty string]
ErrorDetail
I/O Exception: Premature EOF encountered
Filecontent
Connection Failure
Header
[empty string]
Mimetype
Unable to determine MIME type of file.
Responseheader
struct [empty]
Statuscode
Connection Failure. Status code unavailable.
Text
YES


After a lot of tweaking I finally tried using <cfx_http5> which has been around for years because of the limitations of <cfhttp>.
Bam. There it was. Problem solved.

For the record: I have consumed many web services and this is the first time I've had to resolve to <cfx_http5>. I have always gotten around the problems using <cfinvoke> or <cfhttp>. I think many web services are unnecessary complex. Especially when it comes to returning simple datasets.

I really don't understand why Adobe can't get cfhttp to work as nicely as cfx_http5 does.

By the way; this was done using CF9 and although Coldfusion 10 is out now, I haven't been able to test if there are improvements in the forementioned tags.

No comments: