private static void SaveResponse(doStructuredSearchResponse response, string samplesDir) { doSearchResponseType doSearchResponseType = new doSearchResponseType(); doSearchResponseType.SearchResponseMessage = response.SearchResponseMessage; string xmlResponse = SerializationUtils.SerializeToXmlString(doSearchResponseType, "doSearchResponse", "http://usdoj.gov/leisp/lexs/searchretrieve/3.1"); string xmlFilePath = samplesDir + Path.DirectorySeparatorChar + "SearchRetrieveResponse.xml"; XmlDocument outputXmlDoc = new XmlDocument(); outputXmlDoc.LoadXml(xmlResponse); outputXmlDoc.Save(xmlFilePath); Console.WriteLine("The response was saved to : " + 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; }