Last active
October 8, 2015 17:08
-
-
Save JeffJacobson/3362569 to your computer and use it in GitHub Desktop.
ArcGIS Server 10.1 SOE output format bug workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// <para>ArcGIS Server 10.1 introduced a bug that causes the output format to always be set to "json" | |
/// even if another format (e.g., "xml") is specified via the "f" parameter in the HTTP request. | |
/// This method reads the "f" parameter from the <paramref name="operationInput"/> and sets the | |
/// <paramref name="outputFormat"/> to be the same value as the "f" parameter.</para> | |
/// <para>If there is no "f" parameter in <paramref name="operationInput"/> then | |
/// <paramref name="outputFormat"/> will retain its original value.</para> | |
/// </summary> | |
/// <param name="boundVariables"></param> | |
/// <param name="outputFormat"></param> | |
/// <example> | |
/// <code> | |
/// <![CDATA[public byte[] HandleRESTRequest(string Capabilities, string resourceName, string operationName, string operationInput, string outputFormat, string requestProperties, out string responseProperties) | |
/// { | |
/// // ArcGIS 10.1 bug workaround. | |
/// GetActualFormat(operationInput, ref outputFormat); | |
/// return _reqHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, out responseProperties); | |
/// }]]> | |
/// </code> | |
/// </example> | |
private void GetActualFormat(string operationInput, ref string outputFormat) | |
{ | |
if (string.IsNullOrEmpty(operationInput)) return; | |
var json = new JsonObject(operationInput); | |
GetActualFormat(json, ref outputFormat); | |
} | |
/// <summary> | |
/// <para>ArcGIS Server 10.1 introduced a bug that causes the output format to always be set to "json" | |
/// even if another format (e.g., "xml") is specified via the "f" parameter in the HTTP request. | |
/// This method reads the "f" parameter from the <paramref name="operationInput"/> and sets the | |
/// <paramref name="outputFormat"/> to be the same value as the "f" parameter.</para> | |
/// <para>If there is no "f" parameter in <paramref name="operationInput"/> then | |
/// <paramref name="outputFormat"/> will retain its original value.</para> | |
/// </summary> | |
/// <param name="boundVariables"></param> | |
/// <param name="outputFormat"></param> | |
/// <example> | |
/// <code> | |
/// <![CDATA[public byte[] HandleRESTRequest(string Capabilities, string resourceName, string operationName, string operationInput, string outputFormat, string requestProperties, out string responseProperties) | |
/// { | |
/// // ArcGIS 10.1 bug workaround. | |
/// GetActualFormat(operationInput, ref outputFormat); | |
/// return _reqHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, out responseProperties); | |
/// }]]> | |
/// </code> | |
/// </example> | |
private void GetActualFormat(JsonObject operationInput, ref string outputFormat) | |
{ | |
string f; | |
if (operationInput.TryGetString("f", out f)) | |
{ | |
outputFormat = f; | |
} | |
} |
Example usage
public byte[] HandleRESTRequest(string Capabilities, string resourceName, string operationName, string operationInput, string outputFormat, string requestProperties, out string responseProperties)
{
// ArcGIS 10.1 bug workaround.
GetActualFormat(operationInput, ref outputFormat);
return _reqHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, out responseProperties);
}
You da man! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this workaround will not help you if you are trying to export HTML. For now, if you need to export HTML you can have the user specify a value other than
html
for f (e.g.,htm
orhtml5
) and use this workaround.