I have a console application that is sending an XML payload to a SOAP endpoint. I am getting error below when i try to submit the payload :
Log Written Date: 29/1/2020 1:23:59 PM
Error Line No : ine 101
Error Message: SoapException
Exception Type: System.Web.Services.Protocols.SoapException
Error Location : Exception Caught during processing: The element type "SSC" must be terminated by the matching end-tag "</SSC>".
This is despite that my XML is well-formed (at least in the code).
This is how im sending the payload :
transactions = GetContracts();
try
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.Append("<SSC>");
sb.Append("<User>");
sb.Append("<Name>" + Helpers.parameters.sscUser + "</Name>");
sb.Append("</User>");
sb.Append("</SunSystemsContext>");
sb.Append("<BusinessUnit>" + Convert.ToString(Helpers.parameters.busUnit) + "</BusinessUnit>");
sb.Append("<BudgetCode>" + Convert.ToString(Helpers.parameters.budgetCode) + "</BudgetCode>");
sb.Append("</SunSystemsContext>");
sb.Append("<Payload>");
foreach (Contracts contract in transactions) {
sb.Append("<Ledger>");
sb.Append("<EntryPeriod>" + contract.Period + "</EntryPeriod>");
sb.Append("<TransactionAmount>" + contract.Amount + "</TransactionAmount>");
sb.Append("<AnalysisCode1>" + contract.CompanyCode + "</AnalysisCode1>");
sb.Append("</Ledger>");
}
sb.Append("</Payload>");
sb.Append("</SSC>");
var inputPayload = sb.ToString();
if (authVoucher != null)
{
bool result = securityProvider.Validate(authVoucher);
if (result == true)
{
try
{
string outresult = componentExecutor.Execute(authVoucher, "", ComponentName, ComponentMethod, "", inputPayload);
}
catch (Exception ex)
{
ExceptionLogging.SendErrorToText(ex);
string outresult = ex.Message.ToString();
Console.WriteLine(outresult);
What I have tried:
I have pasted a sample of my payload on a online XML validator and im getting error Root element is missing.
This seems an environment related issue and of all the solutions i searched i havent had any luck :
1. I have Verified that my .user file has no NULLS
2. I have Verified that my .csproj file is not empty
3. Searched for the line
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
in .csproj file but its not even there. I got a suggestion to comment out this file in some forum
3. navigated to C:\Users\<your user="">\Documents\Visual Studio <vs version="">\Backup Files\<your project=""> to check if there is both
Recovered an
Original files . What i get is two sets of both types of files
Original-May-18-2018-1209PM.<your project>.csproj
Recovered-May-18-2018-1209PM.<your project>.csproj
and as suggested i have renamed the
Original set to <my_project>.csproj as suggested
I am stii getting the same XML validation error despite these changes.
What am i missing?