[mapguide-commits] r7298 - in trunk/MgDev: Common/Foundation/System Common/MapGuideCommon/Services Common/PlatformBase/Services Server/src/Services/Feature Web/src/ApacheAgent Web/src/CgiAgent Web/src/HttpHandler Web/src/IsapiAgent Web/src/MapAgentCommon

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jan 11 19:54:41 PST 2013


Author: jng
Date: 2013-01-11 19:54:41 -0800 (Fri, 11 Jan 2013)
New Revision: 7298

Added:
   trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.cpp
   trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.h
   trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.cpp
   trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.h
   trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.h
   trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.cpp
   trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.h
Modified:
   trunk/MgDev/Common/Foundation/System/Util.cpp
   trunk/MgDev/Common/Foundation/System/Util.h
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.cpp
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.h
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.h
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h
   trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp
   trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.h
   trunk/MgDev/Common/PlatformBase/Services/Reader.h
   trunk/MgDev/Server/src/Services/Feature/ServerDataReader.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerDataReader.h
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.h
   trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.h
   trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.h
   trunk/MgDev/Web/src/ApacheAgent/ApacheAgent.vcxproj
   trunk/MgDev/Web/src/ApacheAgent/ApacheResponseHandler.cpp
   trunk/MgDev/Web/src/ApacheAgent/Makefile.am
   trunk/MgDev/Web/src/CgiAgent/CgiAgent.vcxproj
   trunk/MgDev/Web/src/CgiAgent/CgiResponseHandler.cpp
   trunk/MgDev/Web/src/CgiAgent/Makefile.am
   trunk/MgDev/Web/src/HttpHandler/HttpExecuteSqlQuery.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpHandler.h
   trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj
   trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj.filters
   trunk/MgDev/Web/src/HttpHandler/HttpHandlerBuild.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpRequestResponseHandler.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpSelectFeatures.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp
   trunk/MgDev/Web/src/HttpHandler/Makefile.am
   trunk/MgDev/Web/src/IsapiAgent/IsapiAgent.vcxproj
   trunk/MgDev/Web/src/IsapiAgent/IsapiResponseHandler.cpp
   trunk/MgDev/Web/src/MapAgentCommon/MapAgentStrings.cpp
Log:
Merge RFC 130 to trunk from our sandbox

Modified: trunk/MgDev/Common/Foundation/System/Util.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/Foundation/System/Util.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -1012,6 +1012,14 @@
     str = &buf[0];
 }
 
+void MgUtil::Int32ToHexString(INT32 val, string& str)
+{
+    char buf[32] = { 0 };
+
+    ::sprintf(buf, "%x", val);
+    str = &buf[0];
+}
+
 void MgUtil::UInt32ToString(UINT32 val, string& str)
 {
     char buf[32] = { 0 };

Modified: trunk/MgDev/Common/Foundation/System/Util.h
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/Foundation/System/Util.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -542,6 +542,7 @@
 
     static void Int32ToString(INT32 val, string& str);
     static void Int32ToString(INT32 val, STRING& str);
+    static void Int32ToHexString(INT32 val, string& str);
     static void UInt32ToString(UINT32 val, string& str);
     static void UInt32ToString(UINT32 val, STRING& str);
     static void Int64ToString(INT64 val, string& str);

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -682,23 +682,77 @@
     CHECKNULL((MgPropertyDefinitionCollection*)m_propDefCol, L"MgProxyDataReader.ToXml");
 
     // this XML follows the SelectAggregate-1.0.0.xsd schema
-    str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-    str += "<PropertySet>";
-    m_propDefCol->ToXml(str);
-    str += "<Properties>";
+    ResponseStartUtf8(str);
+    HeaderToStringUtf8(str);
+    BodyStartUtf8(str);
     while ( this->ReadNext() )
     {
+        CurrentToStringUtf8(str);
+    }
+    BodyEndUtf8(str);
+    ResponseEndUtf8(str);
+}
+
+string MgProxyDataReader::GetResponseElementName()
+{
+    return "PropertySet";
+}
+
+string MgProxyDataReader::GetBodyElementName()
+{
+    return "Properties";
+}
+
+void MgProxyDataReader::ResponseStartUtf8(string& str)
+{
+    str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+    str += "<";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxyDataReader::ResponseEndUtf8(string& str)
+{
+    str += "</";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxyDataReader::BodyStartUtf8(string& str)
+{
+    str += "<";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxyDataReader::BodyEndUtf8(string& str)
+{
+    str += "</";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxyDataReader::HeaderToStringUtf8(string& str)
+{
+    if (NULL != (MgPropertyDefinitionCollection*)m_propDefCol)
+    {
+        m_propDefCol->ToXml(str);
+    }
+}
+
+void MgProxyDataReader::CurrentToStringUtf8(string& str)
+{
+    if (NULL != (MgBatchPropertyCollection*)m_set)
+    {
         Ptr<MgPropertyCollection> propCol = m_set->GetItem(m_currRecord-1);
         INT32 cnt = propCol->GetCount();
         if (propCol != NULL && cnt > 0)
         {
             str += "<PropertyCollection>";
-            propCol->ToXml(str,false);
+            propCol->ToXml(str, false);
             str += "</PropertyCollection>";
         }
     }
-    str += "</Properties>";
-    str += "</PropertySet>";
 }
 
 void MgProxyDataReader::SetService(MgFeatureService* service)

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyDataReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -515,6 +515,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetBodyElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Gets the string value of the specified property. No conversion is

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -833,24 +833,79 @@
     {
         // TODO: define a schema for this XML
         // TODO: rename FeatureSet element to avoid conflict with FeatureSet-1.0.0.xsd?
-        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-        str += "<FeatureSet>";
-        classDef->ToXml(str);
-        str += "<Features>";
+        ResponseStartUtf8(str);
+        HeaderToStringUtf8(str);
+        BodyStartUtf8(str);
         while ( this->ReadNext() )
         {
-            Ptr<MgPropertyCollection> propCol = m_set->GetFeatureAt(m_currRecord-1);
-            INT32 cnt = propCol->GetCount();
-            if (propCol != NULL && cnt > 0)
-            {
-                propCol->ToFeature(str);
-            }
+            CurrentToStringUtf8(str);
         }
-        str += "</Features>";
-        str += "</FeatureSet>";
+        BodyEndUtf8(str);
+        ResponseEndUtf8(str);
     }
 }
 
+string MgProxyFeatureReader::GetResponseElementName()
+{
+    return "FeatureSet";
+}
+
+string MgProxyFeatureReader::GetBodyElementName()
+{
+    return "Features";
+}
+
+void MgProxyFeatureReader::ResponseStartUtf8(string& str)
+{
+    str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+    str += "<";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxyFeatureReader::ResponseEndUtf8(string& str)
+{
+    str += "</";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxyFeatureReader::BodyStartUtf8(string& str)
+{
+    str += "<";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxyFeatureReader::BodyEndUtf8(string& str)
+{
+    str += "</";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxyFeatureReader::HeaderToStringUtf8(string& str)
+{
+    Ptr<MgClassDefinition> classDef = this->GetClassDefinition();
+    if (classDef != NULL)
+    {
+        classDef->ToXml(str);
+    }
+}
+
+void MgProxyFeatureReader::CurrentToStringUtf8(string& str)
+{
+    if (NULL != (MgFeatureSet*)m_set)
+    {
+        Ptr<MgPropertyCollection> propCol = m_set->GetFeatureAt(m_currRecord-1);
+        INT32 cnt = propCol->GetCount();
+        if (propCol != NULL && cnt > 0)
+        {
+            propCol->ToFeature(str);
+        }
+    }
+}
+
 void MgProxyFeatureReader::SetService(MgFeatureService* service)
 {
     CHECKNULL(service, L"MgProxyFeatureReader.SetService");

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyFeatureReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -488,6 +488,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetBodyElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Gets the definition of the object currently being read. If the user

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -768,24 +768,79 @@
     {
         // TODO: define a schema for this XML
         // TODO: rename FeatureSet element to avoid conflict with FeatureSet-1.0.0.xsd?
-        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-        str += "<FeatureSet>";
-        classDef->ToXml(str);
-        str += "<Features>";
+        ResponseStartUtf8(str);
+        HeaderToStringUtf8(str);
+        BodyStartUtf8(str);
         while ( this->ReadNext() )
         {
-            Ptr<MgPropertyCollection> propCol = m_set->GetFeatureAt(m_currRecord-1);
-            INT32 cnt = propCol->GetCount();
-            if (propCol != NULL && cnt > 0)
-            {
-                propCol->ToFeature(str);
-            }
+            CurrentToStringUtf8(str);
         }
-        str += "</Features>";
-        str += "</FeatureSet>";
+        BodyEndUtf8(str);
+        ResponseEndUtf8(str);
     }
 }
 
+string MgProxyGwsFeatureReader::GetResponseElementName()
+{
+    return "FeatureSet";
+}
+
+string MgProxyGwsFeatureReader::GetBodyElementName()
+{
+    return "Features";
+}
+
+void MgProxyGwsFeatureReader::ResponseStartUtf8(string& str)
+{
+    str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+    str += "<";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxyGwsFeatureReader::ResponseEndUtf8(string& str)
+{
+    str += "</";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxyGwsFeatureReader::BodyStartUtf8(string& str)
+{
+    str += "<";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxyGwsFeatureReader::BodyEndUtf8(string& str)
+{
+    str += "</";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxyGwsFeatureReader::HeaderToStringUtf8(string& str)
+{
+	Ptr<MgClassDefinition> classDef = this->GetClassDefinition();
+    if (classDef != NULL)
+	{
+		classDef->ToXml(str);
+	}
+}
+
+void MgProxyGwsFeatureReader::CurrentToStringUtf8(string& str)
+{
+	if (NULL != (MgFeatureSet*)m_set)
+	{
+		Ptr<MgPropertyCollection> propCol = m_set->GetFeatureAt(m_currRecord-1);
+		INT32 cnt = propCol->GetCount();
+		if (propCol != NULL && cnt > 0)
+		{
+			propCol->ToFeature(str);
+		}
+	}
+}
+
 void MgProxyGwsFeatureReader::SetService(MgFeatureService* service)
 {
     CHECKNULL(service, L"MgProxyGwsFeatureReader.SetService");

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyGwsFeatureReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -462,6 +462,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetBodyElementName();
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void ResponseStartUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void ResponseEndUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void BodyStartUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void BodyEndUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Gets the definition of the object currently being read. If the user

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -680,12 +680,68 @@
     CHECKNULL((MgPropertyDefinitionCollection*)m_propDefCol, L"MgProxySqlDataReader.ToXml");
 
     // this XML follows the SqlSelect-1.0.0.xsd schema
-    str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-    str += "<RowSet>";
-    m_propDefCol->ToColumnDefinitions(str);
-    str += "<Rows>";
+    ResponseStartUtf8(str);
+    HeaderToStringUtf8(str);
+    BodyStartUtf8(str);
     while ( this->ReadNext() )
     {
+        CurrentToStringUtf8(str);
+    }
+    BodyEndUtf8(str);
+    ResponseEndUtf8(str);
+}
+
+string MgProxySqlDataReader::GetResponseElementName()
+{
+    return "RowSet";
+}
+
+string MgProxySqlDataReader::GetBodyElementName()
+{
+    return "Rows";
+}
+
+void MgProxySqlDataReader::ResponseStartUtf8(string& str)
+{
+    str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+    str += "<";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxySqlDataReader::ResponseEndUtf8(string& str)
+{
+    str += "</";
+    str += GetResponseElementName();
+    str += ">";
+}
+
+void MgProxySqlDataReader::BodyStartUtf8(string& str)
+{
+    str += "<";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxySqlDataReader::BodyEndUtf8(string& str)
+{
+    str += "</";
+    str += GetBodyElementName();
+    str += ">";
+}
+
+void MgProxySqlDataReader::HeaderToStringUtf8(string& str)
+{
+    if (NULL != (MgPropertyDefinitionCollection*)m_propDefCol)
+    {
+        m_propDefCol->ToColumnDefinitions(str);
+    }
+}
+
+void MgProxySqlDataReader::CurrentToStringUtf8(string& str)
+{
+    if (NULL != (MgBatchPropertyCollection*)m_set)
+    {
         Ptr<MgPropertyCollection> propCol = m_set->GetItem(m_currRecord-1);
         INT32 cnt = propCol->GetCount();
         if (propCol != NULL && cnt > 0)
@@ -693,8 +749,6 @@
             propCol->ToRow(str);
         }
     }
-    str += "</Rows>";
-    str += "</RowSet>";
 }
 
 void MgProxySqlDataReader::SetService(MgFeatureService* service)

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxySqlDataReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -485,6 +485,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetBodyElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Gets the string value of the specified property. No conversion is

Modified: trunk/MgDev/Common/PlatformBase/Services/Reader.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/Reader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Common/PlatformBase/Services/Reader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -1138,6 +1138,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetResponseElementName() = 0;
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual string GetBodyElementName() = 0;
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	virtual void ResponseStartUtf8(string& str) = 0;
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	virtual void ResponseEndUtf8(string& str) = 0;
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	virtual void BodyStartUtf8(string& str) = 0;
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	virtual void BodyEndUtf8(string& str) = 0;
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    virtual void HeaderToStringUtf8(string& str) = 0;
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    virtual void CurrentToStringUtf8(string& str) = 0;
+
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Gets the string value of the specified property. No conversion is

Modified: trunk/MgDev/Server/src/Services/Feature/ServerDataReader.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerDataReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerDataReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -1512,6 +1512,54 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
+string MgServerDataReader::GetResponseElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.GetResponseElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+string MgServerDataReader::GetBodyElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.GetBodyElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerDataReader::ResponseStartUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.ResponseStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerDataReader::ResponseEndUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.ResponseEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerDataReader::BodyStartUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.BodyStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerDataReader::BodyEndUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.BodyEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerDataReader::HeaderToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.HeaderToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerDataReader::CurrentToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerDataReader.CurrentToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
 MgByteReader* MgServerDataReader::GetRaster(INT32 xSize, INT32 ySize, STRING rasterPropName)
 {
     CHECKNULL(m_dataReader, L"MgServerDataReader.GetRaster");

Modified: trunk/MgDev/Server/src/Services/Feature/ServerDataReader.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerDataReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerDataReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -436,6 +436,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetBodyElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// <summary>
     /// Gets the string value of the specified property. No conversion is

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -865,7 +865,54 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
+string MgServerFeatureReader::GetResponseElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.GetResponseElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
 
+string MgServerFeatureReader::GetBodyElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.GetBodyElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerFeatureReader::ResponseStartUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.ResponseStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerFeatureReader::ResponseEndUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.ResponseEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerFeatureReader::BodyStartUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.BodyStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerFeatureReader::BodyEndUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.BodyEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerFeatureReader::HeaderToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.HeaderToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerFeatureReader::CurrentToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerFeatureReader.CurrentToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
 //////////////////////////////////////////////////////////////////
 /// <summary>
 /// Releases all the resources of feature reader.

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -401,6 +401,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetBodyElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// <summary>
     /// Gets the definition of the object currently being read. If the user

Modified: trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -1234,7 +1234,54 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
+string MgServerGwsFeatureReader::GetResponseElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.GetResponseElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
 
+string MgServerGwsFeatureReader::GetBodyElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.GetBodyElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerGwsFeatureReader::ResponseStartUtf8(string& str)
+{
+	throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.ResponseStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerGwsFeatureReader::ResponseEndUtf8(string& str)
+{
+	throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.ResponseEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerGwsFeatureReader::BodyStartUtf8(string& str)
+{
+	throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.BodyStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerGwsFeatureReader::BodyEndUtf8(string& str)
+{
+	throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.BodyEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerGwsFeatureReader::HeaderToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.HeaderToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerGwsFeatureReader::CurrentToStringUtf8(string& str)
+{
+	throw new MgInvalidOperationException(L"MgServerGwsFeatureReader.CurrentToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
 //////////////////////////////////////////////////////////////////
 /// <summary>
 /// Releases all the resources of feature reader.

Modified: trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerGwsFeatureReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -393,6 +393,86 @@
     /// </summary>
     void Close();
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetBodyElementName();
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void ResponseStartUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void ResponseEndUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void BodyStartUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+	void BodyEndUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+	///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// <summary>
     /// Serializes all features into an XML.

Modified: trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -1352,6 +1352,54 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
+string MgServerSqlDataReader::GetResponseElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.GetResponseElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+string MgServerSqlDataReader::GetBodyElementName()
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.GetBodyElementName",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerSqlDataReader::ResponseStartUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.ResponseStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerSqlDataReader::ResponseEndUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.ResponseEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerSqlDataReader::BodyStartUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.BodyStartUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerSqlDataReader::BodyEndUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.BodyEndUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerSqlDataReader::HeaderToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.HeaderToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgServerSqlDataReader::CurrentToStringUtf8(string& str)
+{
+    throw new MgInvalidOperationException(L"MgServerSqlDataReader.CurrentToStringUtf8",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
 /// <summary>Gets the raster object of the specified property.
 /// the property must be of Raster type; otherwise, an exception is thrown.
 /// </summary>

Modified: trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Server/src/Services/Feature/ServerSqlDataReader.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -411,6 +411,86 @@
 
 INTERNAL_API:
 
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetResponseElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the body starting element name as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+	///
+    string GetBodyElementName();
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void ResponseEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the start of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyStartUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the end of the response body as a UTF-8 string. The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void BodyEndUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the header in this reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void HeaderToStringUtf8(string& str);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Returns the contents of the current record/feature in the reader as a UTF-8 string.  The mime
+    /// type must be a text type, for example text/xml.
+    ///
+    /// \param str
+    /// Destination string.
+    ///
+    void CurrentToStringUtf8(string& str);
+
     //////////////////////////////////////////////////////////////////
     /// <summary>
     /// Gets the string value of the specified property. No conversion is

Modified: trunk/MgDev/Web/src/ApacheAgent/ApacheAgent.vcxproj
===================================================================
--- trunk/MgDev/Web/src/ApacheAgent/ApacheAgent.vcxproj	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/ApacheAgent/ApacheAgent.vcxproj	2013-01-12 03:54:41 UTC (rev 7298)
@@ -224,6 +224,7 @@
   <ItemGroup>
     <ClCompile Include="ApacheAgent.cpp" />
     <ClCompile Include="ApachePostParser.cpp" />
+    <ClCompile Include="ApacheReaderStreamer.cpp" />
     <ClCompile Include="ApacheResponseHandler.cpp" />
   </ItemGroup>
   <ItemGroup>
@@ -231,6 +232,7 @@
   </ItemGroup>
   <ItemGroup>
     <CustomBuildStep Include="ApachePostParser.h" />
+    <ClInclude Include="ApacheReaderStreamer.h" />
     <ClInclude Include="ApacheResponseHandler.h" />
   </ItemGroup>
   <ItemGroup>

Copied: trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.cpp (from rev 7287, sandbox/jng/streaming/Web/src/ApacheAgent/ApacheReaderStreamer.cpp)
===================================================================
--- trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.cpp	                        (rev 0)
+++ trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,22 @@
+#include "ApacheReaderStreamer.h"
+#include "http_protocol.h"
+
+ApacheReaderStreamer::ApacheReaderStreamer(request_rec* rec, MgReader* reader, CREFSTRING format) :
+    MgHttpReaderStreamer(reader, format), m_r(rec)
+{
+}
+
+ApacheReaderStreamer::~ApacheReaderStreamer() { }
+
+void ApacheReaderStreamer::SetChunkedEncoding() 
+{
+    //Setting chunked to 1 enables chunked transfer encoding. No need to manually
+    //write out chunk delimiters and fragments
+    m_r->chunked = 1; 
+}
+
+void ApacheReaderStreamer::WriteChunk(const char* str, size_t length)
+{
+    //Each ap_rwrite call is considered an individual chunk when m_r->chunked is set to 1
+    ap_rwrite(str, length, m_r);
+}
\ No newline at end of file

Copied: trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.h (from rev 7287, sandbox/jng/streaming/Web/src/ApacheAgent/ApacheReaderStreamer.h)
===================================================================
--- trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.h	                        (rev 0)
+++ trunk/MgDev/Web/src/ApacheAgent/ApacheReaderStreamer.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,38 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef APACHE_READER_STREAMER_H
+#define APACHE_READER_STREAMER_H
+
+#include "MapGuideCommon.h"
+#include "httpd.h"
+#include "HttpHandler.h"
+
+class ApacheReaderStreamer : public MgHttpReaderStreamer
+{
+public:
+    ApacheReaderStreamer(request_rec* rec, MgReader* reader, CREFSTRING format);
+    virtual ~ApacheReaderStreamer();
+
+protected:
+    virtual void SetChunkedEncoding();
+    virtual void WriteChunk(const char* str, size_t length);
+
+private:
+    request_rec* m_r;
+};
+
+#endif
\ No newline at end of file

Modified: trunk/MgDev/Web/src/ApacheAgent/ApacheResponseHandler.cpp
===================================================================
--- trunk/MgDev/Web/src/ApacheAgent/ApacheResponseHandler.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/ApacheAgent/ApacheResponseHandler.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -16,6 +16,7 @@
 //
 
 #include "ApacheResponseHandler.h"
+#include "ApacheReaderStreamer.h"
 #include "MapAgentStrings.h"
 
 #include "httpd.h"
@@ -97,6 +98,7 @@
             m_r->content_type = apr_pstrdup(m_r->pool, tempHeader);
         }
 
+        Ptr<MgReader> outputDataReader;
         Ptr<MgByteReader> outputReader;
         Ptr<MgDisposable> resultObj = result->GetResultObject();
         MgDisposable* pResultObj = (MgDisposable*)resultObj;
@@ -107,7 +109,7 @@
         }
         else if (NULL != dynamic_cast<MgFeatureReader*>(pResultObj))
         {
-            outputReader = ((MgFeatureReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgFeatureReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgStringCollection*>(pResultObj))
         {
@@ -115,11 +117,11 @@
         }
         else if (NULL != dynamic_cast<MgSqlDataReader*>(pResultObj))
         {
-            outputReader = ((MgSqlDataReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgSqlDataReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgDataReader*>(pResultObj))
         {
-            outputReader = ((MgDataReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgDataReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgSpatialContextReader*>(pResultObj))
         {
@@ -142,8 +144,12 @@
 
             ap_send_http_header(m_r);
             ap_rwrite(utf8.c_str(), (int)utf8.length(), m_r);
-
         }
+        else if (outputDataReader != NULL)
+        {
+            ApacheReaderStreamer ars(m_r, outputDataReader, result->GetResultContentType());
+            ars.StreamResult();
+        }
         else if (outputReader != NULL)
         {
             INT64 outLen = outputReader->GetLength();

Modified: trunk/MgDev/Web/src/ApacheAgent/Makefile.am
===================================================================
--- trunk/MgDev/Web/src/ApacheAgent/Makefile.am	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/ApacheAgent/Makefile.am	2013-01-12 03:54:41 UTC (rev 7298)
@@ -23,6 +23,7 @@
 
 mod_mgmapagent_la_SOURCES = ApacheAgent.cpp \
                             ApachePostParser.cpp \
+                            ApacheReaderStreamer.cpp \
                             ApacheResponseHandler.cpp \
                             ../MapAgentCommon/MapAgentCommon.cpp \
                             ../MapAgentCommon/MapAgentGetParser.cpp \
@@ -30,6 +31,7 @@
                             ../WebSupport/InitializeWebTier.cpp
 
 noinst_HEADERS = ApachePostParser.h \
+                 ApacheReaderStreamer.h \
                  ApacheResponseHandler.h \
                  ../MapAgentCommon/MapAgentCommon.h \
                  ../MapAgentCommon/MapAgentGetParser.h \

Modified: trunk/MgDev/Web/src/CgiAgent/CgiAgent.vcxproj
===================================================================
--- trunk/MgDev/Web/src/CgiAgent/CgiAgent.vcxproj	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/CgiAgent/CgiAgent.vcxproj	2013-01-12 03:54:41 UTC (rev 7298)
@@ -190,6 +190,7 @@
   <ItemGroup>
     <ClCompile Include="CgiAgent.cpp" />
     <ClCompile Include="CgiPostParser.cpp" />
+    <ClCompile Include="CgiReaderStreamer.cpp" />
     <ClCompile Include="CgiResponseHandler.cpp" />
     <ClCompile Include="EchoTest.cpp" />
   </ItemGroup>
@@ -198,6 +199,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="CgiPostParser.h" />
+    <ClInclude Include="CgiReaderStreamer.h" />
     <ClInclude Include="CgiResponseHandler.h" />
   </ItemGroup>
   <ItemGroup>

Copied: trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.cpp (from rev 7287, sandbox/jng/streaming/Web/src/CgiAgent/CgiReaderStreamer.cpp)
===================================================================
--- trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.cpp	                        (rev 0)
+++ trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,66 @@
+#include "CgiReaderStreamer.h"
+#include "MapAgentStrings.h"
+
+extern void DumpMessage(const char* format, ...);
+extern void DumpMessage2(const char* msg);
+
+CgiReaderStreamer::CgiReaderStreamer(MgReader* reader, CREFSTRING format) :
+    MgHttpReaderStreamer(reader, format),
+    m_bEndOfStream(false)
+{
+}
+
+CgiReaderStreamer::~CgiReaderStreamer() 
+{ 
+    EndStream();
+}
+
+void CgiReaderStreamer::EndStream()
+{
+    if (!m_bEndOfStream)
+    {
+        //Write end of chunked response
+        printf("0\r\n\r\n");
+        m_bEndOfStream = true;
+    }
+}
+
+void CgiReaderStreamer::SetChunkedEncoding() 
+{
+    printf("Connection: Keep-Alive");
+    printf(MapAgentStrings::CrLf);
+    printf("Transfer-Encoding: chunked");
+    printf(MapAgentStrings::CrLf);
+    printf(MapAgentStrings::CrLf);
+}
+
+void CgiReaderStreamer::WriteChunk(const char* str, size_t length)
+{
+    /*
+    std::string logStr = "BEGIN - CgiReaderStreamer::WriteChunk";
+    logStr.append(" str='");
+    logStr.append(str);
+    logStr.append("', length=");
+    MgUtil::ReplaceString("%", "%%", logStr, -1);
+    std::string lengthStr;
+    MgUtil::Int32ToString(length, lengthStr);
+    logStr.append(lengthStr);
+    DumpMessage(logStr.c_str());
+    */
+    
+    m_hexLen.clear();
+    MgUtil::Int32ToHexString(length, m_hexLen);
+    m_hexLen.append(MapAgentStrings::CrLf);
+
+    printf(m_hexLen.c_str());
+    //---- BEGIN chunk body ----//
+    //Need to escape any characters that may trip up printf
+    //Currently it is: '%'
+    m_sCurrentChunk.clear();
+    m_sCurrentChunk = str;
+    MgUtil::ReplaceString("%", "%%", m_sCurrentChunk, -1);
+    printf(m_sCurrentChunk.c_str());
+    //---- END chunk body ----//
+    printf(MapAgentStrings::CrLf);
+    //DumpMessage("END - CgiReaderStreamer::WriteChunk");
+}
\ No newline at end of file

Copied: trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.h (from rev 7287, sandbox/jng/streaming/Web/src/CgiAgent/CgiReaderStreamer.h)
===================================================================
--- trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.h	                        (rev 0)
+++ trunk/MgDev/Web/src/CgiAgent/CgiReaderStreamer.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,41 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef CGI_READER_STREAMER_H
+#define CGI_READER_STREAMER_H
+
+#include "MapGuideCommon.h"
+#include "HttpHandler.h"
+
+class CgiReaderStreamer : public MgHttpReaderStreamer
+{
+public:
+    CgiReaderStreamer(MgReader* reader, CREFSTRING format);
+    virtual ~CgiReaderStreamer();
+
+protected:
+    virtual void SetChunkedEncoding();
+    virtual void WriteChunk(const char* str, size_t length);
+    virtual void EndStream();
+
+private:
+    bool m_bEndOfStream;
+    std::string m_hexLen;
+    std::string m_sCurrentChunk;
+};
+
+#endif
\ No newline at end of file

Modified: trunk/MgDev/Web/src/CgiAgent/CgiResponseHandler.cpp
===================================================================
--- trunk/MgDev/Web/src/CgiAgent/CgiResponseHandler.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/CgiAgent/CgiResponseHandler.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -19,6 +19,7 @@
 #include "HttpHandler.h"
 #include "HttpPrimitiveValue.h"
 #include "CgiResponseHandler.h"
+#include "CgiReaderStreamer.h"
 #include "MapAgentStrings.h"
 
 #include <stdlib.h>
@@ -101,6 +102,7 @@
             printf(MapAgentStrings::ContentTypeHeader, MapAgentStrings::TextPlain, MapAgentStrings::Utf8Text);
         }
 
+        Ptr<MgReader> outputDataReader;
         Ptr<MgByteReader> outputReader;
         Ptr<MgDisposable> resultObj = result->GetResultObject();
         MgDisposable* pResultObj = (MgDisposable*)resultObj;
@@ -111,7 +113,7 @@
         }
         else if (NULL != dynamic_cast<MgFeatureReader*>(pResultObj))
         {
-            outputReader = ((MgFeatureReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgFeatureReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgStringCollection*>(pResultObj))
         {
@@ -119,11 +121,11 @@
         }
         else if (NULL != dynamic_cast<MgSqlDataReader*>(pResultObj))
         {
-            outputReader = ((MgSqlDataReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgSqlDataReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgDataReader*>(pResultObj))
         {
-            outputReader = ((MgDataReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgDataReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgSpatialContextReader*>(pResultObj))
         {
@@ -144,6 +146,11 @@
             printf(MapAgentStrings::ContentLengthHeader, utf8.length());
             printf("\r\n%s",utf8.c_str());
         }
+        else if (outputDataReader != NULL)
+        {
+            CgiReaderStreamer crs(outputDataReader, result->GetResultContentType());
+            crs.StreamResult();
+        }
         else if (outputReader != NULL)
         {
             INT64 outLen = outputReader->GetLength();

Modified: trunk/MgDev/Web/src/CgiAgent/Makefile.am
===================================================================
--- trunk/MgDev/Web/src/CgiAgent/Makefile.am	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/CgiAgent/Makefile.am	2013-01-12 03:54:41 UTC (rev 7298)
@@ -18,6 +18,7 @@
 
 mapagent_SOURCES = CgiAgent.cpp \
                    CgiPostParser.cpp \
+                   CgiReaderStreamer.cpp \
                    CgiResponseHandler.cpp \
                    EchoTest.cpp \
                    ../MapAgentCommon/MapAgentCommon.cpp \
@@ -26,6 +27,7 @@
                    ../WebSupport/InitializeWebTier.cpp
 
 noinst_HEADERS = CgiPostParser.h \
+                 CgiReaderStreamer.h \
                  CgiResponseHandler.h \
                  ../MapAgentCommon/MapAgentCommon.h \
                  ../MapAgentCommon/MapAgentGetParser.h \

Modified: trunk/MgDev/Web/src/HttpHandler/HttpExecuteSqlQuery.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpExecuteSqlQuery.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpExecuteSqlQuery.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -63,12 +63,9 @@
 
     // call the C++ API
     Ptr<MgSqlDataReader> sqlReader = service->ExecuteSqlQuery(resId, m_sqlStatement);
-    Ptr<MgByteReader> byteReader = sqlReader->ToXml();
+    //HACK-ish: We're passing conversion responsibility to the caller (agent), so we store the
+    //originally requested format so the caller can determine if conversion is required
+    hResult->SetResultObject(sqlReader, m_responseFormat);
 
-    //Convert to alternate response format, if necessary
-    ProcessFormatConversion(byteReader);
-
-    hResult->SetResultObject(byteReader, byteReader->GetMimeType());
-
     MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpExecuteSqlQuery.Execute")
 }

Modified: trunk/MgDev/Web/src/HttpHandler/HttpHandler.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpHandler.h	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpHandler.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -33,6 +33,7 @@
 // Common HttpHandler headers
 #include "HttpHandlerApiDllExport.h"
 #include "HttpHeader.h"
+#include "HttpReaderStreamer.h"
 #include "HttpRequestParam.h"
 #include "HttpRequestMetadata.h"
 #include "HttpStatusCodes.h"

Modified: trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj	2013-01-12 03:54:41 UTC (rev 7298)
@@ -306,6 +306,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="HttpReaderStreamer.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="HttpRenameResourceData.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1018,6 +1024,7 @@
     <ClInclude Include="OgcWfsServer.h" />
     <ClInclude Include="OgcWmsException.h" />
     <ClInclude Include="OgcWmsServer.h" />
+    <ClInclude Include="HttpReaderStreamer.h" />
     <ClInclude Include="ResponseStream.h" />
     <ClInclude Include="Stream.h" />
     <ClInclude Include="StringStream.h" />

Modified: trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj.filters
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj.filters	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpHandler.vcxproj.filters	2013-01-12 03:54:41 UTC (rev 7298)
@@ -382,6 +382,7 @@
     <ClCompile Include="HttpUtil.cpp" />
     <ClCompile Include="JsonDoc.cpp" />
     <ClCompile Include="XmlJsonConvert.cpp" />
+    <ClCompile Include="HttpReaderStreamer.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="HttpApplyResourcePackage.h">
@@ -752,6 +753,7 @@
     <ClInclude Include="HttpUtil.h" />
     <ClInclude Include="JsonDoc.h" />
     <ClInclude Include="XmlJsonConvert.h" />
+    <ClInclude Include="HttpReaderStreamer.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="HttpHandler.rc" />

Modified: trunk/MgDev/Web/src/HttpHandler/HttpHandlerBuild.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpHandlerBuild.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpHandlerBuild.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -97,6 +97,7 @@
 #include "HttpMoveResource.cpp"
 #include "HttpPrimitiveValue.cpp"
 #include "HttpQueryMapFeatures.cpp"
+#include "HttpReaderStreamer.cpp"
 #include "HttpRenameResourceData.cpp"
 #include "HttpRequest.cpp"
 #include "HttpRequestMetadata.cpp"

Copied: trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.cpp (from rev 7287, sandbox/jng/streaming/Web/src/HttpHandler/HttpReaderStreamer.cpp)
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.cpp	                        (rev 0)
+++ trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,154 @@
+#include "HttpHandler.h"
+#include "XmlJsonConvert.h"
+
+MgHttpReaderStreamer::MgHttpReaderStreamer(MgReader* reader, CREFSTRING format)
+{
+    m_reader = SAFE_ADDREF(reader);
+    m_format = format;
+}
+
+MgHttpReaderStreamer::~MgHttpReaderStreamer() 
+{
+    m_reader = NULL;
+}
+
+void MgHttpReaderStreamer::SetChunkedEncoding() 
+{
+
+}
+
+void MgHttpReaderStreamer::WriteChunk(const char* str, size_t length)
+{
+
+}
+
+void MgHttpReaderStreamer::EndStream() { }
+
+void MgHttpReaderStreamer::StreamResult()
+{
+    MG_TRY()
+
+    SetChunkedEncoding();
+
+    if (m_format == MgMimeType::Json)
+    {
+        std::string buf;
+        std::string jsonbuf;
+
+        //How this looks:
+        //
+        // {                            //outer JSON start
+        //   "ResponseElementName":     //root element name
+        //     {                        //root JSON property start
+        //      <header JSON pair>,
+        //      "BodyElementName":[     //body JSON array start
+        //
+        jsonbuf = "{\"";
+        jsonbuf += m_reader->GetResponseElementName();
+        jsonbuf += "\":{";
+        m_reader->HeaderToStringUtf8(buf);
+        std::string jsonbuf2;
+        ToJson(buf, jsonbuf2);
+        //This will have redudant outer { }, so strip them
+        jsonbuf2.erase(0, 1);
+        jsonbuf2.erase(jsonbuf2.length() - 2, 1);
+        //HACK: To match the original output, we have to array-ify this object (crazy? yes!)
+        //
+        //We currently have something like this
+        //
+        // "HeaderElementName":{
+        //    <prop1>:<val1>,
+        //    <prop2>:<val2>
+        // }
+        //
+        //We have to change it to this
+        //
+        // "HeaderElementName":[{
+        //    <prop1>:<val1>,
+        //    <prop2>:<val2>
+        // }]
+
+        //Find first instance of ": and insert [ after it. We use ": because a feature
+        //reader puts out xs:schema as the header element name
+        jsonbuf2.insert(jsonbuf2.find("\":") + 2, "[");
+        //Append ] to the end
+        jsonbuf2.append("]");
+
+        jsonbuf += jsonbuf2;
+        jsonbuf += ",\"";
+        jsonbuf += m_reader->GetBodyElementName();
+        jsonbuf += "\":[";
+
+        WriteChunk(jsonbuf.c_str(), jsonbuf.length());
+
+        bool bNext = m_reader->ReadNext();
+        while(bNext)
+        {
+            buf.clear();
+            jsonbuf.clear();
+            m_reader->CurrentToStringUtf8(buf);
+            //The body is a valid full XML element, so no need for gymnastics like its
+            //surrounding elements
+            ToJson(buf, jsonbuf);
+
+            //Strip outer { }
+            jsonbuf.erase(0, 1);
+            jsonbuf.erase(jsonbuf.length() - 2, 1);
+            //HACK: Same as the header, this needs to be array-ified to match the old output
+            //
+            //Find first instance of ": and insert [ after it.
+            jsonbuf.insert(jsonbuf.find("\":") + 2, "[");
+            //Append ] to the end
+            jsonbuf.append("]");
+            //Put back in outer { }
+            jsonbuf = "{" + jsonbuf;
+            jsonbuf += "}";
+
+            bNext = m_reader->ReadNext();
+            if (bNext)
+                jsonbuf += ",";
+            WriteChunk(jsonbuf.c_str(), jsonbuf.length());
+        }
+
+        buf.clear();
+        jsonbuf.clear();
+
+        // How this looks:
+        //      ]   //End of body JSON array
+        //    }     //End of root JSON property
+        // }        //End of outer JSON
+        jsonbuf = "]}}";
+        WriteChunk(jsonbuf.c_str(), jsonbuf.length());
+    }
+    else if (m_format == MgMimeType::Xml)
+    {
+        std::string buf;
+        m_reader->ResponseStartUtf8(buf);
+        m_reader->HeaderToStringUtf8(buf);
+        m_reader->BodyStartUtf8(buf);
+
+        WriteChunk(buf.c_str(), buf.length());
+
+        while(m_reader->ReadNext())
+        {
+            buf.clear();
+            m_reader->CurrentToStringUtf8(buf);
+            WriteChunk(buf.c_str(), buf.length());
+        }
+
+        buf.clear();
+
+        m_reader->BodyEndUtf8(buf);
+        m_reader->ResponseEndUtf8(buf);
+
+        WriteChunk(buf.c_str(), buf.length());
+    }
+
+    MG_CATCH_AND_THROW(L"MgHttpReaderStreamer.StreamResult");
+}
+
+void MgHttpReaderStreamer::ToJson(string& xmlString, string& jsonString)
+{
+    MgXmlJsonConvert convert;
+    convert.ToJson(xmlString, jsonString);
+}
\ No newline at end of file

Copied: trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.h (from rev 7287, sandbox/jng/streaming/Web/src/HttpHandler/HttpReaderStreamer.h)
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.h	                        (rev 0)
+++ trunk/MgDev/Web/src/HttpHandler/HttpReaderStreamer.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,43 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef MG_HTTP_READER_STREAMER_H
+#define MG_HTTP_READER_STREAMER_H
+
+/// <summary>
+/// Purpose of this class is to provide a common base class for streaming out the contents of
+/// an MgReader instance via chunked response encoding
+/// </summary>
+class MG_MAPAGENT_API MgHttpReaderStreamer : public MgGuardDisposable
+{
+public:
+    void StreamResult();
+    virtual ~MgHttpReaderStreamer();
+
+protected:
+    MgHttpReaderStreamer(MgReader* reader, CREFSTRING format);
+    virtual void SetChunkedEncoding();
+    virtual void WriteChunk(const char* str, size_t length);
+    virtual void Dispose() { delete this; }
+    virtual void EndStream();
+    
+private:
+    void ToJson(string& xmlString, string& jsonString);
+    Ptr<MgReader> m_reader;
+    STRING m_format;
+};
+
+#endif
\ No newline at end of file

Modified: trunk/MgDev/Web/src/HttpHandler/HttpRequestResponseHandler.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpRequestResponseHandler.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpRequestResponseHandler.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -277,5 +277,4 @@
         MgXmlJsonConvert convert;
         convert.ToJson(byteReader);
     }
-}
-
+}
\ No newline at end of file

Modified: trunk/MgDev/Web/src/HttpHandler/HttpSelectFeatures.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpSelectFeatures.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpSelectFeatures.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -104,12 +104,9 @@
     }
 
     Ptr<MgFeatureReader> featureReader = service->SelectFeatures(&resId, m_className, qryOptions);
-    Ptr<MgByteReader> byteReader = featureReader->ToXml();
+    //HACK-ish: We're passing conversion responsibility to the caller (agent), so we store the
+    //originally requested format so the caller can determine if conversion is required
+    hResult->SetResultObject(featureReader, m_responseFormat);
 
-    //Convert to alternate response format, if necessary
-    ProcessFormatConversion(byteReader);
-
-    hResult->SetResultObject(byteReader, byteReader->GetMimeType());
-
     MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpSelectFeatures.Execute")
 }

Modified: trunk/MgDev/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -114,12 +114,9 @@
     }
 
     Ptr<MgDataReader> dataReader = service->SelectAggregate(&resId, m_className, qryOptions);
-    Ptr<MgByteReader> byteReader = dataReader->ToXml();
+    //HACK-ish: We're passing conversion responsibility to the caller (agent), so we store the
+    //originally requested format so the caller can determine if conversion is required
+    hResult->SetResultObject(dataReader, m_responseFormat);
 
-    //Convert to alternate response format, if necessary
-    ProcessFormatConversion(byteReader);
-
-    hResult->SetResultObject(byteReader, byteReader->GetMimeType());
-
     MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpSelectFeaturesSpatially.Execute")
 }

Modified: trunk/MgDev/Web/src/HttpHandler/Makefile.am
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/Makefile.am	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/HttpHandler/Makefile.am	2013-01-12 03:54:41 UTC (rev 7298)
@@ -100,6 +100,7 @@
   HttpMoveResource.cpp \
   HttpPrimitiveValue.cpp \
   HttpQueryMapFeatures.cpp \
+  HttpReaderStreamer.cpp \
   HttpRenameResourceData.cpp \
   HttpRequest.cpp \
   HttpRequestMetadata.cpp \
@@ -228,6 +229,7 @@
   HttpPrimitiveValue.h \
   HttpPrimitiveValueTypes.h \
   HttpQueryMapFeatures.h \
+  HttpReaderStreamer.h \
   HttpRenameResourceData.h \
   HttpRequest.h \
   HttpRequestMetadata.h \

Modified: trunk/MgDev/Web/src/IsapiAgent/IsapiAgent.vcxproj
===================================================================
--- trunk/MgDev/Web/src/IsapiAgent/IsapiAgent.vcxproj	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/IsapiAgent/IsapiAgent.vcxproj	2013-01-12 03:54:41 UTC (rev 7298)
@@ -186,6 +186,7 @@
   <ItemGroup>
     <ClCompile Include="IsapiAgent.cpp" />
     <ClCompile Include="IsapiPostParser.cpp" />
+    <ClCompile Include="IsapiReaderStreamer.cpp" />
     <ClCompile Include="IsapiResponseHandler.cpp" />
   </ItemGroup>
   <ItemGroup>
@@ -196,6 +197,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="IsapiPostParser.h" />
+    <ClInclude Include="IsapiReaderStreamer.h" />
     <ClInclude Include="IsapiResponseHandler.h" />
     <ClInclude Include="stdafx.h" />
   </ItemGroup>

Copied: trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.cpp (from rev 7287, sandbox/jng/streaming/Web/src/IsapiAgent/IsapiReaderStreamer.cpp)
===================================================================
--- trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.cpp	                        (rev 0)
+++ trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,56 @@
+#include "MapGuideCommon.h"
+#include "HttpHandler.h"
+#include "IsapiReaderStreamer.h"
+#include "MapAgentStrings.h"
+
+IsapiReaderStreamer::IsapiReaderStreamer(EXTENSION_CONTROL_BLOCK* rec, const std::string& sResponseHeader, MgReader* reader, CREFSTRING format) :
+    MgHttpReaderStreamer(reader, format), 
+    m_pECB(rec), 
+    m_sResponseHeader(sResponseHeader), 
+    m_bEndOfStream(false)
+{
+    m_hexLen.reserve(32);
+}
+
+IsapiReaderStreamer::~IsapiReaderStreamer() 
+{
+    EndStream();
+}
+
+void IsapiReaderStreamer::EndStream()
+{
+    if (!m_bEndOfStream)
+    {
+        //Write end of chunked response
+        DWORD len = 5;
+        m_pECB->WriteClient(m_pECB->ConnID, "0\r\n\r\n", &len, 0);
+
+        m_bEndOfStream = true;
+    }
+}
+
+void IsapiReaderStreamer::SetChunkedEncoding() 
+{
+    m_sResponseHeader.append("Connection: Keep-Alive\r\n");
+    m_sResponseHeader.append("Transfer-Encoding: chunked\r\n");
+    m_sResponseHeader.append("\r\n");
+
+    DWORD dwHeaderSize = (DWORD)m_sResponseHeader.length();
+    m_pECB->ServerSupportFunction(m_pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, NULL, &dwHeaderSize, (LPDWORD)m_sResponseHeader.c_str());
+}
+
+void IsapiReaderStreamer::WriteChunk(const char* str, size_t length)
+{
+    m_hexLen.clear();
+    MgUtil::Int32ToHexString(length, m_hexLen);
+    m_hexLen.append(MapAgentStrings::CrLf);
+
+    DWORD len = m_hexLen.size();
+    m_pECB->WriteClient(m_pECB->ConnID, (LPVOID)m_hexLen.data(), &len, 0);
+
+    len = (DWORD)length;
+    m_pECB->WriteClient(m_pECB->ConnID, (LPVOID)str, &len, 0);
+
+    len = 2;
+    m_pECB->WriteClient(m_pECB->ConnID, (LPVOID)MapAgentStrings::CrLf, &len, 0);
+}
\ No newline at end of file

Copied: trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.h (from rev 7287, sandbox/jng/streaming/Web/src/IsapiAgent/IsapiReaderStreamer.h)
===================================================================
--- trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.h	                        (rev 0)
+++ trunk/MgDev/Web/src/IsapiAgent/IsapiReaderStreamer.h	2013-01-12 03:54:41 UTC (rev 7298)
@@ -0,0 +1,41 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef ISAPI_READER_STREAMER_H
+#define ISAPI_READER_STREAMER_H
+
+#include "HttpExt.h"
+#include "HttpHandler.h"
+
+class IsapiReaderStreamer : public MgHttpReaderStreamer
+{
+public:
+    IsapiReaderStreamer(EXTENSION_CONTROL_BLOCK* rec, const std::string& sResponseHeader, MgReader* reader, CREFSTRING format);
+    virtual ~IsapiReaderStreamer();
+
+protected:
+    virtual void SetChunkedEncoding();
+    virtual void WriteChunk(const char* str, size_t length);
+    virtual void EndStream();
+
+private:
+    EXTENSION_CONTROL_BLOCK *m_pECB;
+    std::string m_hexLen;
+    std::string m_sResponseHeader;
+    bool m_bEndOfStream;
+};
+
+#endif
\ No newline at end of file

Modified: trunk/MgDev/Web/src/IsapiAgent/IsapiResponseHandler.cpp
===================================================================
--- trunk/MgDev/Web/src/IsapiAgent/IsapiResponseHandler.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/IsapiAgent/IsapiResponseHandler.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -19,6 +19,7 @@
 #include "HttpHandler.h"
 #include "HttpPrimitiveValue.h"
 #include "IsapiResponseHandler.h"
+#include "IsapiReaderStreamer.h"
 #include "MapAgentStrings.h"
 
 #include <stdlib.h>
@@ -102,6 +103,7 @@
             sResponseHeader.append(tempHeader);
         }
 
+        Ptr<MgReader> outputDataReader;
         Ptr<MgByteReader> outputReader;
         Ptr<MgDisposable> resultObj = result->GetResultObject();
         MgDisposable* pResultObj = (MgDisposable*)resultObj;
@@ -112,7 +114,7 @@
         }
         else if (NULL != dynamic_cast<MgFeatureReader*>(pResultObj))
         {
-            outputReader = ((MgFeatureReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgFeatureReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgStringCollection*>(pResultObj))
         {
@@ -120,11 +122,11 @@
         }
         else if (NULL != dynamic_cast<MgSqlDataReader*>(pResultObj))
         {
-            outputReader = ((MgSqlDataReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgSqlDataReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgDataReader*>(pResultObj))
         {
-            outputReader = ((MgDataReader*)pResultObj)->ToXml();
+            outputDataReader = SAFE_ADDREF((MgDataReader*)pResultObj); //Need to AddRef because there's now 2 references on this pointer
         }
         else if (NULL != dynamic_cast<MgSpatialContextReader*>(pResultObj))
         {
@@ -151,6 +153,11 @@
             DWORD dwBufLen = (DWORD)utf8.length();
             m_pECB->WriteClient(m_pECB->ConnID, (LPVOID)utf8.c_str(), &dwBufLen, 0);
         }
+        else if (outputDataReader != NULL)
+        {
+            IsapiReaderStreamer irs(m_pECB, sResponseHeader, outputDataReader, result->GetResultContentType());
+            irs.StreamResult();
+        }
         else if (outputReader != NULL)
         {
             INT64 outLen = outputReader->GetLength();

Modified: trunk/MgDev/Web/src/MapAgentCommon/MapAgentStrings.cpp
===================================================================
--- trunk/MgDev/Web/src/MapAgentCommon/MapAgentStrings.cpp	2013-01-12 03:36:03 UTC (rev 7297)
+++ trunk/MgDev/Web/src/MapAgentCommon/MapAgentStrings.cpp	2013-01-12 03:54:41 UTC (rev 7298)
@@ -64,7 +64,6 @@
 const char* MapAgentStrings::WWWAuthKey = "WWW-Authenticate";
 const char* MapAgentStrings::WWWAuthVal = "Basic realm=\"%s\"";
 
-
 const wchar_t* MapAgentStrings::WebConfig = L"../webconfig.ini";
 const wchar_t* MapAgentStrings::FailedAuth1 = L"MgAuthenticationFailedException";
 const wchar_t* MapAgentStrings::FailedAuth2 = L"MgUnauthorizedAccessException";



More information about the mapguide-commits mailing list