bbthao

how to read json for a map service that is in Chinese language

Discussion created by bbthao on Jun 9, 2011
Latest reply on Jun 13, 2011 by rnarayanan-esristaff
WE have a map service name similar to below:

http://<machine name>:8399/arcgis/rest/services/????????????mapservice/MapServer

When going to browser using the above URL but the name is encoded as below, I can see the map service

http://<machine name>:8399/arcgis/rest/services/%E4%B8%AD%E6%96%87MapServices/MapServer

This encoded URL was given to me and I don't know how it was done.

In code, to read json for the map service, I do the following:

var client = new System.Net.WebClient();
StreamReader reader = null;
try
{
      reader = new StreamReader(client.OpenRead(this.MapURL + "?f=json"));                       
}...
if(reader != null)
    mapJsonResult = reader.ReadToEnd();

this.MapURL is encoded using:
System.Web.HttpUtility.UrlPathEncode(mapURLSb.ToString());

mapURLsb is the map service URL.
However, the line reader.ReadToEnd(); has problem, the message is
"\r\n\r\n\r\n\r\n{\r\n\"error\" : {\r\n\t\"code\" : 404,\r\n\t\"message\" : \"Service '????????????mapservice' of type 'MapServer' does not exist or is inaccessible.\",\r\n\t\"details\":[\r\n\t\r\n\t]\r\n}\r\n}"

As I checked, my encoded mapURL is not the same as the one given. 
My encoded url:
"http://<machine name>:8399/arcgis/rest/services/%e5%9c%b0%e5%9b%be%e6%9c%8d%e5%8a%a1mapservice/MapServer"

If I paste the given encoded URL as mentioned on top to my mapURL, it works.  I don't know what I should do or what is wrong with my code.  Please help!!!

Thanks!

Outcomes