I have asmx service & when on browser i run url. at that time i am getting xml + json response.
my service code:
namespace CTSWebApp.Service
{
/// <summary>
/// Summary description for GetShipperConsignee
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class GetShipperConsignee : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string GetAutoList(string SearchText)
{
List<ShipperDTO> shipperList = new List<ShipperDTO>();
ShipperApp shipperApp = new ShipperApp();
shipperList = shipperApp.GetShipper(SearchText);
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string m_json = serializer.Serialize(shipperList);
return m_json;
}
}
}
Now, when i run url on browser. My response is:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">List :[{"VendorId":18,"Name":"GRIP RITE","Address1":"530B NE 42ND COURT","Address2":"","State":"FL","City":"FT LAUDERDALE","Zip":"33334"},{"VendorId":1003895,"Name":"GRIP RITE","Address1":"214-A BICKLEY RD","Address2":"","State":"SC","City":"LEXINGTON","Zip":"29072"},{"VendorId":1009453,"Name":"GRIFFIN PLATING CO","Address1":"1636 WEST ARMITAGE AVE.","Address2":"","State":"IL","City":"CHICAGO","Zip":"60622"},{"VendorId":1012716,"Name":"GRIFFIN TRANSPORT SERVICE","Address1":"5360 CAPITAL COURT","Address2":"STE 100","State":"NV","City":"RENO","Zip":"89502"},{"VendorId":1016190,"Name":"GRIFFIN GREENHOUSE","Address1":"7141 OLD RUTLEDGE PIKE","Address2":"","State":"TN","City":"KNOXVILLE","Zip":"37924"},{"VendorId":1016668,"Name":"GRIOT\u0027S GARAGE INC","Address1":"3333 S 38TH STREET","Address2":"","State":"WA","City":"TACOMA","Zip":"98409"},{"VendorId":1017354,"Name":"GRIFFIN EXPRESS","Address1":"12 CRESCENT STREET","Address2":"","State":"MA","City":"HOLYOKE","Zip":"01040"},{"VendorId":1018691,"Name":"GRIFFIN INDUSTRIES","Address1":"1001 ORIENT ROAD","Address2":"","State":"FL","City":"TAMPA","Zip":"33619"},{"VendorId":1022522,"Name":"GRIND LAP SERVICES","Address1":"1045 WEST NATIONAL","Address2":"","State":"IL","City":"ADDISON","Zip":"60101"},{"VendorId":1022552,"Name":"GRISWOLD CORPORATION","Address1":"ONE RIVER STREET","Address2":"","State":"CT","City":"MOOSUP","Zip":"06354"},{"VendorId":1027089,"Name":"GRIGNARD COMPANY","Address1":"505 CAPOBIANCO PLAZA BLDG","Address2":"","State":"NJ","City":"RAHWAY","Zip":"07065"}]</string>
also i add code on config file.
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory" validate="false"/>
</httpHandlers>
i think. i done everything what required to get json response. also i checked on Internet but they all are same way which i done.
Kindly let me know. what i am making wrong.
Thanks