AnsweredAssumed Answered

How to Send Parameter to SOE through HTTP based services?

Question asked by shaikhrizuan on Sep 20, 2019
Latest reply on Sep 24, 2019 by shaikhrizuan

Hi,

I am having "Location" parameter where 'x' & 'y' value has to pass in SOE to process the request.Below is the C# code to access the SOE request.

// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("https://myServer.com:6443/arcgis/rest/services/ITDService/MapServer/exts/DistanceSOE/SpatialQuery");
// Set the Method property of the request to POST.
request.Method = "POST";

// Create POST data and convert it to a byte array.
string postData = "{\"Location\": {\"x\": 84.44902820440936,\"y\": 21.300696836245145}}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);

// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;

// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();

// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);

// Get the stream containing content returned by the server.
// The using block ensures the stream is automatically closed.
using (dataStream = response.GetResponseStream())
{
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
}

It is going to SOE but could not able to read the "Location" Parameter and its values. PFB image for the same.

Can anyone let know, how parameters need to be send?

Outcomes