diff --git a/cllc-interfaces/OneStopRestClient/OneStopRestClient.cs b/cllc-interfaces/OneStopRestClient/OneStopRestClient.cs index 17cbfe9fc5..14771982bd 100644 --- a/cllc-interfaces/OneStopRestClient/OneStopRestClient.cs +++ b/cllc-interfaces/OneStopRestClient/OneStopRestClient.cs @@ -21,14 +21,18 @@ public OneStopRestClient(Uri baseUri, string authorizationHeaderValue, ILogger l this._logger = logger; } - public async Task ReceiveFromPartner(string inputXml) + public string CleanXML(string inputXml) { - var url = $"{BaseUri}?inputXML={Uri.EscapeDataString(inputXml)}"; - // clean any namespaces. inputXml = Regex.Replace(inputXml, @" xmlns:.*?"".*?""", ""); // adjust the header. inputXml = inputXml.Replace("encoding=\"utf-16\"?>", "?>"); + return inputXml; + } + + public async Task ReceiveFromPartner(string inputXml) + { + var url = $"{BaseUri}?inputXML={Uri.EscapeDataString(inputXml)}"; Log.Logger.Information($"InputXML to send = {inputXml}"); @@ -53,6 +57,7 @@ public interface IOneStopRestClient { Uri BaseUri { get; set; } string AuthorizationHeaderValue { get; set; } + string CleanXML(string inputXml); Task ReceiveFromPartner(string inputXml); } } diff --git a/one-stop-service/OneStopUtils.cs b/one-stop-service/OneStopUtils.cs index 43a426aa00..fd001cc7d5 100644 --- a/one-stop-service/OneStopUtils.cs +++ b/one-stop-service/OneStopUtils.cs @@ -153,21 +153,23 @@ public async Task SendChangeAddressRest(PerformContext hangfireContext, string l } else { - var innerXML = req.CreateXML(licence); + var innerXml = req.CreateXML(licence); + innerXml = _onestopRestClient.CleanXML(innerXml); if (Log.Logger != null) { - Log.Logger.Information(innerXML); + Log.Logger.Information(innerXml); } if (hangfireContext != null) { - hangfireContext.WriteLine(innerXML); + hangfireContext.WriteLine(innerXml); } //send message to Onestop hub - var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML); - UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML); + + var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml); + UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML); if (hangfireContext != null) { @@ -222,24 +224,25 @@ public async Task SendChangeNameRest(PerformContext hangfireContext, string lice targetBusinessNumber = targetOwner.Accountnumber; } } - var innerXML = req.CreateXML(licence, isTransfer, targetBusinessNumber); + var innerXml = req.CreateXML(licence, isTransfer, targetBusinessNumber); + innerXml = _onestopRestClient.CleanXML(innerXml); if (Log.Logger != null) { - Log.Logger.Information(innerXML); + Log.Logger.Information(innerXml); } if (hangfireContext != null) { - hangfireContext.WriteLine(innerXML); + hangfireContext.WriteLine(innerXml); } //send message to Onestop hub - var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML); + var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml); - UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML); + UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML); if (hangfireContext != null) { @@ -287,22 +290,23 @@ public async Task SendChangeStatusRest(PerformContext hangfireContext, string li { - var innerXML = req.CreateXML(licence, statusChange); + var innerXml = req.CreateXML(licence, statusChange); + innerXml = _onestopRestClient.CleanXML(innerXml); if (Log.Logger != null) { - Log.Logger.Information(innerXML); + Log.Logger.Information(innerXml); } if (hangfireContext != null) { - hangfireContext.WriteLine(innerXML); + hangfireContext.WriteLine(innerXml); } //send message to Onestop hub - var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML); + var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml); - UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXML, outputXML); + UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML); if (hangfireContext != null) { @@ -352,13 +356,15 @@ public async Task SendProgramAccountRequestREST(PerformContext hangfireContext, { var innerXml = req.CreateXML(licence, suffix); + + innerXml = _onestopRestClient.CleanXML(innerXml); + Log.Logger?.Information(innerXml); // send message to Onestop hub var outputXml = await _onestopRestClient.ReceiveFromPartner(innerXml); UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXml); - if (hangfireContext != null) { hangfireContext.WriteLine(outputXml); @@ -417,20 +423,22 @@ public async Task SendProgramAccountDetailsBroadcastMessageRest(PerformContext h } else { - var innerXML = req.CreateXML(licence); + var innerXml = req.CreateXML(licence); + + innerXml = _onestopRestClient.CleanXML(innerXml); if (Log.Logger != null) { - Log.Logger.Information(innerXML); + Log.Logger.Information(innerXml); } if (hangfireContext != null) { - hangfireContext.WriteLine(innerXML); + hangfireContext.WriteLine(innerXml); } //send message to Onestop hub - var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXML); + var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml); if (hangfireContext != null) {