1

I searched the previous questions about this problem but I could not get the solution about it. My problem is I'm requested Bing Maps' REST services from my asmx web service and I want to return Json from my method. Also I published my web service to Azure and when I call it, it returned like this. How can I fix this problem?

<string xmlns="http://tempuri.org/">
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">Json elements in here</string>
</string>

Also here is my asmx service code:

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

    public string GetBingRoute(string sourcelat, string sourcelong, string deslat, string deslong, string type)
    {

        //type should be Walking or Driving

        string address = "http://dev.virtualearth.net/REST/V1/Routes/" + type + "/?o=json&wp.0=" + sourcelat + "," + sourcelong + "&wp.1=" + deslat + "," + deslong + "&timeWithTraffic&key=_MYKEY_";

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream resStream = response.GetResponseStream();

        StreamReader sr = new StreamReader(resStream);
        return sr.ReadToEnd();

    }
  • Is this a duplicate of [How to get JSON response from a 3.5 asmx web service](https://stackoverflow.com/questions/19563641/how-to-get-json-response-from-a-3-5-asmx-web-service) ? – dbc May 20 '16 at 22:24

0 Answers0