ArcIMS_SendArcXML_CSharp\ArcXML.aspx.cs
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using ESRI.ArcGIS.ADF.Connection.IMS; public partial class ArcXML : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //System.Net.ServicePointManager.Expect100Continue = false; } private String unescapeXML(String req) { String reqlt = req.Replace("<", "<"); String reqgt = reqlt.Replace(">", ">"); String reqquot = reqgt.Replace(""", "\""); String reqamp = reqquot.Replace("&", "&"); //String reqapos = reqamp.Replace("'", "'"); return reqamp; } protected void button_send_ServerClick(object sender, EventArgs e) { try { IMSServerConnection connection = null; if (RadioButtonListScheme.SelectedValue == "TCP") { connection = new TCPConnection(); TCPConnection tcpconnection = (TCPConnection)connection; tcpconnection.Host = text_server.Value; tcpconnection.Port = Int32.Parse(text_port.Value); connection.ServiceName = text_service.Value; } else if (RadioButtonListScheme.SelectedValue == "HTTP") { connection = new HTTPConnection(text_server.Value); HTTPConnection httpconnection = (HTTPConnection) connection; if (text_port.Value != "80") httpconnection.Port = Int32.Parse(text_port.Value); httpconnection.User = "private"; httpconnection.Password = "pass.word"; connection.ServiceName = text_service.Value; } /*** Get ArrayList of ArcIMS service names *** System.Collections.ArrayList arraylist = connection.ClientServicesArray(); IEnumerator arrayenum = arraylist.GetEnumerator(); while (arrayenum.MoveNext()) { string servicename = (string)arrayenum.Current; } */ String CustomService = null; if (checkbox_query.Checked) { CustomService = "Query"; } else if (checkbox_geocode.Checked) { CustomService = "Geocode"; } else if (checkbox_extract.Checked) { CustomService = "Extract"; } String request = unescapeXML(textarea_request.Value); String prolog = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; String axlrequest = prolog + request; String axlresponse = connection.Send(axlrequest, CustomService); textarea_response.Value = axlresponse; } catch (Exception ex) { textarea_response.Value = ex.Message; } } protected void RadioButtonListScheme_SelectedIndexChanged(object sender, EventArgs e) { if (RadioButtonListScheme.SelectedValue == "TCP") { text_server.Value = "localhost"; text_port.Value = "5300"; } else if (RadioButtonListScheme.SelectedValue == "HTTP") { text_server.Value = "http://localhost"; text_port.Value = "80"; } } }