Usługa sieciowa Asmx zwracająca xml zamiast json, Próba usunięcia <string xmlns = „http://tempuri.org/”> z wyjścia usługi

Szukałem 100 linków dla ostatnich 3 godzin, np. Dodawanie skryptów do webconfig, 3 błędy, ustawianie typu treści itp.

Nie jestem w stanie zrozumieć, czym właściwie jest błąd.

Środowisko: Usługa uruchomiona na aplikacji sieciowej .net 4.0 działającej na .net 4.0

Wymagania: Muszę powiązać jqGrid z usługą internetową asmx, która zwraca mi json jako łańcuch.Plik usługi sieci Web zawiera następujący kod.

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class SampleService : System.Web.Services.WebService
{
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string GetJsonServerProcess()
    {
        int memory = 1;
        string json = string.Empty;
        var obj = (System.Diagnostics.Process.GetProcesses().Where(r => r.WorkingSet64 > memory).Select(p => new { p.ProcessName, p.WorkingSet64 }).ToArray());
        json = Lib.ToJSON(obj);
        return json;
    }
}

Javascript jest następujący

<script type="text/javascript">
    $(document).ready(function () {
        jQuery("#jqgajax").jqGrid({
            ajaxGridOptions: { type: "POST", contentType: 'application/json; charset=utf-8'  },
            url:'http://localhost:1092/SampleService.asmx/GetJsonServerProcess',
            datatype: "json",
            data: "{}",
            colNames: ['ProcessName', 'WorkingSet64'],
            colModel: [
                        { name: 'ProcessName', index: 'ProcessName', width: 55 },
                        { name: 'WorkingSet64', index: 'WorkingSet64', width: 90 }
                    ],
            rowNum: 10,
            width: 700,
            rowList: [10, 20, 30],
            sortname: 'invdate',
            viewrecords: true,
            sortorder: "desc",
            caption: "New API Example"
        });
    });
</script>

HTML jest następujący

<table id="jqgajax">
</table>
<div id="jqgajax">
</div>

Dane wyjściowe usługi sieci Web po kliknięciu przycisku Wywołaj

<string xmlns="http://tempuri.org/">
[{"ProcessName":"Dropbox","WorkingSet64":22736896},
 {"ProcessName":"fdhost","WorkingSet64":1941504},
 {"ProcessName":"IntelliTrace","WorkingSet64":39276544}
]
</string>

Proszę zasugerować, co tam jest, czego mi brakuje.<string xmlns="http://tempuri.org/"> Tagi mnie irytują. Zakładam, że te tagi nie pozwalają mojej sieci na wiązanie.

AKTUALIZACJA:

Usługa ASMX wygląda teraz jak poniżej.

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class SampleService : System.Web.Services.WebService
{
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public List<demo> GetJsonServerProcess()
    {
        List<demo> test = new List<demo>();

        for(int i=1;i<=10;i++)
            test.Add(new demo { ProcessName = string.Format("Sample {0}",i), WorkingSet64 = i });

        var re = test;
        return re;
    }
}

public class demo
{
    public string ProcessName { get; set; }
    public int WorkingSet64 { get; set; }
}

questionAnswers(6)

yourAnswerToTheQuestion