Calling gp service from pure .NET

2408
1
06-02-2016 03:11 AM
ModyBuchbinder
Esri Regular Contributor

Hello

I have a gp service I would like to call from .NET program that does not have any ESRI libreries.

This should be easy using the REST calls.

I followed Rex's blog here: http://rexdotnet.blogspot.co.il/2009/11/using-arcgis-server-rest-api-in-net.html

The example runs a geocoder and not gp service.

You can see my code below. The service is running, I get result but it is only include some metadata on the request like service name and version.

I should be able to get an event when the request is done and get the full results.

Anybody is doing it?

           string requestUri =
               "http://mody-pc:6080/arcgis/rest/services/RestCall/GPServer";
            
            StringBuilder data = new StringBuilder();
            data.AppendFormat("?f={0}", "json");
           data.AppendFormat("&str1={0}&str2={1}", System.Web.HttpUtility.UrlEncode(StreetTextBox.Text),
                System.Web.HttpUtility.UrlEncode(ZoneTextBox.Text));
            
            HttpWebRequest request = WebRequest.Create(requestUri + data) as HttpWebRequest;


            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());


                string responseString = reader.ReadToEnd();
0 Kudos
1 Reply
springzhang
New Contributor II

Hi Mody, have you figured it out?

0 Kudos