Ok, I know I must be missing something simple.
Thank-you for your help!
[EDITED to clarify]
The problem I'm having is that the JSON input is not being deserialized properly or something and is giving me an empty XML result. I want the output in XML format, I just don't want it to be blank.
The code is a simplified version of my actual code. In my real code I'm retreiving the JSON from another website, and I'm trying to parse it and return it in an XML soap request.
To simplify things, I took the JSON string and simply hard coded it as an example.
[WebService(Namespace="my.soap")]
public class StockQuote : WebService
{
[WebMethod(Description="",EnableSession=false)]
public ResultSet IBM()
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = "{\"ResultSet\":{\"Query\":\"ibm\",\"Result\":[{\"symbol\":\"IBM\",\"name\": \"International Business Machines Corp.\",\"exch\": \"NYQ\",\"type\": \"S\",\"exchDisp\":\"NYSE\",\"typeDisp\":\"Equity\"},{\"symbol\":\"IBM.F\",\"name\": \"IBM\",\"exch\": \"FRA\",\"type\": \"S\",\"exchDisp\":\"Frankfurt\",\"typeDisp\":\"Equity\"},{\"symbol\":\"IBM.DE\",\"name\": \"IBM\",\"exch\": \"GER\",\"type\": \"S\",\"exchDisp\":\"XETRA\",\"typeDisp\":\"Equity\"},{\"symbol\":\"^AXI\",\"name\": \"Stlmt ID - NASDAQ OMX Alpha IBM\",\"exch\": \"NAS\",\"type\": \"I\",\"exchDisp\":\"NASDAQ\",\"typeDisp\":\"Index\"},{\"symbol\":\"^IVSPY\",\"name\": \"NASDAQ OMX Alpha IBM vs. SPY\",\"exch\": \"NAS\",\"type\": \"I\",\"exchDisp\":\"NASDAQ\",\"typeDisp\":\"Index\"},{\"symbol\":\"IBMSX\",\"name\": \"Invesco Multi-Sector B\",\"exch\": \"NAS\",\"type\": \"M\",\"exchDisp\":\"NASDAQ\",\"typeDisp\":\"Fund\"},{\"symbol\":\"IBM.BE\",\"name\": \"IBM\",\"exch\": \"BER\",\"type\": \"S\",\"exchDisp\":\"Berlin\",\"typeDisp\":\"Equity\"},{\"symbol\":\"IBM.SG\",\"name\": \"IBM\",\"exch\": \"STU\",\"type\": \"S\",\"exchDisp\":\"Stuttgart\",\"typeDisp\":\"Equity\"},{\"symbol\":\"IBM.BA\",\"name\": \"International Business Machines Corp.\",\"exch\": \"BUE\",\"type\": \"S\",\"exchDisp\":\"Buenos Aires\",\"typeDisp\":\"Equity\"},{\"symbol\":\"IBM.L\",\"name\": \"International Business Machines Corp.\",\"exch\": \"LSE\",\"type\": \"S\",\"exchDisp\":\"London\",\"typeDisp\":\"Equity\"}]}}";
return serializer.Deserialize<ResultSet>(json);
}
}
[Serializable]
public class ResultSet
{
public string Query;
public ResSet[] Result;
}
[Serializable]
public class ResSet
{
public string symbol;
public string name;
public string exch;
public string type;
public string exchDisp;
public string typeDisp;
}
I'm getting the following returned by the web service instead of the formatted object:
<?xml version="1.0" encoding="utf-8" ?>
<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="my.soap" />