Hi all,
I've got a pretty unique situation but hear me out! I'm using .NET's WCF to host a web service that accepts and responds to calls wrapped in JSON. For security reasons I can't give you the address of the server (it doesn't respond to requests from off-box) but suffice to say I can send it a string of JSON (using callRemote), it does some work and it returns a JSON object (not an array of objects - this is where I think the problem may lie).
I'm sending in a string which looks like this:
[ { "someField": "ab", "someOtherField": "ab", "anotherField": "{5B4904C9-4D95-465B-A23C-A79349323DA2}" } ]
The service does some work server side and populates an instance of a simple class with a few string, Guid and string array values, which are then serialized as JSON and passed back to MTA. An example response looks like this:
{"fieldA":0,"arrayField":["someValue", "someOtherValue"],"uniqueKey":"yetAnotherValue"}
This is, according to various sources, a valid JSON string - indeed, it passes validation at JSONlint.com - but it doesn't seem to be passed back to my callback method correctly. I'm wondering if this is because it's not an array, like MTA sends it's requests in, but rather a single object. The only response I seem to get is that result==nil.
The method I'm using to hit the WCF service is as follows:
function doCallRemote(entry)
callRemote("http://someaddress/", myCallbackFunction, entry )
end
function myCallbackFunction(result)
if result and result ~="ERROR" then
--all good
elseif result and result == "ERROR" then
outputChatBox(result.." , "..errorcode)
elseif result == nil then
outputChatBox("result: nil")
end
end
Can anyone spot any obvious omissions, errors or lack of knowledge as to why I can't get my JSON object result passed back to my callback function? Any help would be gratefully received.
Daniel