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

713
1
06-09-2011 06:28 AM
ThaoNguyen
New Contributor II
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!
0 Kudos
1 Reply
RaviNarayanan
Esri Contributor
Hello,

there seems to be difference in the URLs that you have provided as examples from the browser and the used in the code.

the service name in the browser URL:
中�??MapServices

the service name used in the code.
�?��?��?��?�mapservice

can you please copy paste the url that works in the browser into the code to make sure there are no differences in the service name?
0 Kudos