public virtual doStructuredSearchResponse doStructuredSearch(doStructuredSearchRequest request)
        {
            try
            {
                string appDataDir = HostingEnvironment.ApplicationPhysicalPath;

                string samplesFolder = ConfigurationManager.AppSettings["SamplesFolder"];
                
                string sampleInstance = ConfigurationManager.AppSettings["ResponseXmlInstance"];
                
                string samplesDir = string.Empty;

                if (appDataDir == null)
                {
                    samplesDir = samplesFolder;
                }
                else
                {
                    samplesDir = appDataDir + Path.DirectorySeparatorChar + samplesFolder;
                }
                
                SaveRequest(request, samplesDir);

                return GetResponse(request, sampleInstance, samplesDir);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Server exception: " + e.ToString());

                throw e;
            }
        }
 private static void DoStructureSearchRequest(ILEXSSearchRetrievePortType proxy, string sampleInstancePath, string sampleXmlInstance)
 {
     doStructuredSearchRequestType requestType = Deserialize(sampleInstancePath,
         sampleXmlInstance, "doStructuredSearchRequest", "http://usdoj.gov/leisp/lexs/searchretrieve/3.1",
         typeof(doStructuredSearchRequestType)) as doStructuredSearchRequestType;
     doStructuredSearchRequest request = new doStructuredSearchRequest(requestType.StructuredSearchRequestMessage);
     doStructuredSearchResponse reponse = proxy.doStructuredSearch(request);
     SaveResponse(reponse, sampleInstancePath);
 }
        private static void SaveRequest(doStructuredSearchRequest request, string samplesDir)
        {
            doStructuredSearchRequestType requestType = new doStructuredSearchRequestType();
            requestType.StructuredSearchRequestMessage = request.StructuredSearchRequestMessage;

            string xmlPublish = SerializationUtils.SerializeToXmlString(requestType,
                "doStructuredSearchRequest", "http://usdoj.gov/leisp/lexs/searchretrieve/3.1");

            string xmlFilePath = samplesDir + Path.DirectorySeparatorChar + "StructuredSearchRequest.xml";

            XmlDocument outputXmlDoc = new XmlDocument();
            outputXmlDoc.LoadXml(xmlPublish);

            outputXmlDoc.Save(xmlFilePath);
        }
        private static doStructuredSearchResponse GetResponse(doStructuredSearchRequest request, string sampleInstance, string samplesDir)
        {
            string xmlFilePath = samplesDir + Path.DirectorySeparatorChar + "" + sampleInstance ;

            if (!File.Exists(xmlFilePath))
            {
                return null;
            }

            string xmlText = SerializationUtils.XmlStringFromFile(xmlFilePath);

            Type type = typeof(doSearchResponseType);

            doSearchResponseType searchResponseType = SerializationUtils.DeserializeFromXmlString(xmlText,
                "doSearchResponse", "http://usdoj.gov/leisp/lexs/searchretrieve/3.1", type) as doSearchResponseType;
            
            doStructuredSearchResponse structuredSearchResponse = new doStructuredSearchResponse(searchResponseType.SearchResponseMessage);
            
            return structuredSearchResponse;
        }