Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

help a .NET developer consume a wcf service using coldfusion

I am a .NET developer with no coldfusion experience, but I need to write cf code to access a wcf service i've set up. I've got a few WCF services being hosted in IIS 7 with WsHttpBinding, and I'm able to use the services fine by adding service references to a .NET client and using client classes.

It is very straightforward for a .NET developer:

var addressClient = new Service.AddressClient();
addressClient.AddressDTO[] addresses = addressClient.GetAddresses();

It's clear that visual studio does a lot behind the scenes to set up these client classes from the WSDL.

I've seen coldfusion examples using cfinvoke to call web services, but none where they actually set up client classes from the WSDL and create them from the web service response.

So, how is something like this done from coldfusion?

Thanks in advance!

like image 532
jeff Avatar asked May 20 '10 14:05

jeff


2 Answers

others are correct in that if your webservice is returning simple data types, cf will map them to cf data types and everything is easy. in some cases though you'll have to covert the complex data types to cf data types yourself.

cflib.org has some function to handle these, so you might want to look there. here is a function to convert a .net dataset being returned from a webservice to a cf query. hopefully this will give you an ah-ha moment:

http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=1580

like image 101
rip747 Avatar answered Sep 19 '22 08:09

rip747


The problem with CF is that is does not do a good job of allowing you to deal with complex objects. So as long as the service is only expecting params of strings and such your OK, but if it wants a complicated nesting of objects it falls apart.

Basically you have to get down to the Axis Java objects.

I answered this once before here:

Web service is expecting a DataSet object, how can I provide that via ColdFusion or in raw XML?

like image 45
ryber Avatar answered Sep 22 '22 08:09

ryber