public void SaveRequest(bool RequestSave, string SaveDirectory) { string RequestFileContent = string.Empty; if (RequestSave) { if (mAct.GetType() == typeof(ActWebAPISoap)) { RequestFileContent = BodyString; mAct.AddOrUpdateInputParamValueAndCalculatedValue(ActWebAPIRest.Fields.ContentType, "XML"); } else if (mAct.GetType() == typeof(ActWebAPIRest)) { if (!string.IsNullOrEmpty(BodyString)) { RequestFileContent = BodyString; } else if ((mAct.RequestKeyValues.Count() > 0) && (mAct.GetInputParamValue(ActWebAPIRest.Fields.ContentType) == "XwwwFormUrlEncoded")) { HttpContent UrlEncoded = new FormUrlEncodedContent(ConstructURLEncoded((ActWebAPIRest)mAct)); RequestFileContent = UrlEncoded.ToString(); } else if ((mAct.RequestKeyValues.Count() > 0) && (mAct.GetInputParamValue(ActWebAPIRest.Fields.ContentType) == "FormData")) { MultipartFormDataContent FormDataContent = new MultipartFormDataContent(); for (int i = 0; i < mAct.RequestKeyValues.Count(); i++) { FormDataContent.Add(new StringContent(mAct.RequestKeyValues[i].ValueForDriver), mAct.RequestKeyValues[i].ItemName.ToString()); } RequestFileContent = FormDataContent.ToString(); } else { RequestFileContent = RequestMessage.ToString(); } } string FileFullPath = Webserviceplatforminfo.SaveToFile("Request", RequestFileContent, SaveDirectory, mAct); mAct.AddOrUpdateReturnParamActual("Saved Request File Name", Path.GetFileName(FileFullPath)); } }
public void SaveResponseToFile(bool saveResponse, string savePath) { if (saveResponse) { string ResponseFileContent = string.Empty; if (mAct.GetType() == typeof(ActWebAPISoap)) { ResponseFileContent = ResponseMessage; mAct.AddOrUpdateInputParamValueAndCalculatedValue(ActWebAPIRest.Fields.ResponseContentType, "XML"); } else if (mAct.GetType() == typeof(ActWebAPIRest)) { if (!string.IsNullOrEmpty(ResponseMessage)) { ResponseFileContent = ResponseMessage; } else { if (Response != null && Response.Headers != null) { ResponseFileContent = Response.Headers.ToString(); } else { ResponseFileContent = string.Empty; } } } ResponseFileContent = Amdocs.Ginger.Common.XMLDocExtended.PrettyXml(ResponseFileContent); string FileFullPath = Webserviceplatforminfo.SaveToFile("Response", ResponseFileContent, savePath, mAct); mAct.AddOrUpdateReturnParamActual("Saved Response File Name", Path.GetFileName(FileFullPath)); } }