Has anyone ever tried returning a ColdFusion structure through a web service? The WSDL type CF assigns to this is apachesoap:Map, but when I consume this in VB.NET, the data is null.
I have converted the entire thing into a JSON string, and that seems to work, but it requires a ton of code on the .NET side to handle. We are trying to do this with a minimal amount of work for our customers.
I've found a "solution". It's not perfect, but it works pretty well. If you use SerializeJSON, it will convert it into a properly formatted JSON string. In this case we are actually returning an array of structures, so instead of serializing the entire object, if you serialize each struct as you append it to the array, it gets returned as a impl:ArrayOf_xsd_anyType SOAP type. .NET has no trouble with this at all. Then there's a couple lines to write in .NET to convert that into objects:
Dim objTemp As Object 'This has to be created as an object instead of an array.
objTemp = WebServiceClass.GetData() 'This would be the web service class created by the Web Reference.
Dim theClass As New MyClass()
Dim theCollection As New MyClassCollection() 'These are your class objects
Dim index As Integer = 0
'Loop through each entity in the object
For index = 0 To objTemp.length - 1
theClass = serializer.Deserialize(Of MyClass)(objTemp(index)) 'Deserialize the JSON data
theCollection.Add(theClass) ' Add it to the collection
The important thing here is that the Class created in .NET must have properties named exactly the same as the keys of the structure. Otherwise, they will not map properly.
I hope this helps someone else out there. I searched for hours to find a solution and found many others having the same problem, with no answer.
Thanks for posting it. Too bad there's no way to trade generic objects back and forth without creating a separate class. But at least you found something that works! That's more than I've seen until now..