我創建WCF服務,查詢Oracle數據庫和JSON format.How返回結果的結果從Oracle查詢轉換到JSON消息返回JSON作爲WCF服務的結果
public class Service1 : IService1
{
public HttpResponseMessage GetData(string ROOM)
{
List<OracleParameter> prms = new List<OracleParameter>();
prms.Add(new OracleParameter("ROOM", OracleDbType.Varchar2, ROOM, ParameterDirection.Input));
string connStr = ConfigurationManager.ConnectionStrings["TGSDataBaseConnection"].ConnectionString; using (OracleConnection dbconn = new OracleConnection(connStr))
{
DataSet userDataset = new DataSet();
var strQuery = "SELECT * from LIMS_SAMPLE_RESULTS_VW where ROOM = :ROOM";
var returnObject = new { data = new OracleDataTableJsonResponse(connStr, strQuery, prms.ToArray()) };
var response = Request.CreateResponse(HttpStatusCode.OK, returnObject, MediaTypeHeaderValue.Parse("application/json"));
ContentDispositionHeaderValue contentDisposition = null;
if (ContentDispositionHeaderValue.TryParse("inline; filename=TGSData.json", out contentDisposition))
{
response.Content.Headers.ContentDisposition = contentDisposition;
}
return response;
}
它拋出一個喜歡的名字是「請求」錯誤不會在目前的情況下存在於線
var response = Request.CreateResponse(HttpStatusCode.OK, returnObject, MediaTypeHeaderValue.Parse("application/json"));
我加入了
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
是什麼反應呢? –
@viveknuna響應是我們從Oracle數據庫 – xyz