0

I'm trying to parse a response from another system that is in XML. I decided to use RapidXML as my parser. Everything was going fine until the system reported a "faultResponse" message. When trying to handle the "faultResponse" message I get a parse error

I made sure I'm capturing the exception code and it says it's a parse error. "Expected <". I'm looking at the sending system and they log what they send, so I know it's not missing an <. I tried xmllint to verify it's a good file and xmllint says it's good

Actual XML being sent from remote system

<FaultResponse sequenceNumber="10004993">
  <Exception type="System.Exception">
    <message>Distribution Exception: </message>
    <detail>System.Exception: Distribution Exception:  ---&gt; System.Exception: Error copying "AcomSubscriber.xds" to "\\ACOM-P40\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P42\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P39\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P41\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P44\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P43\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P47\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P49\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P45\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P48\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P50\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P46\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P51\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
   --- End of inner exception stack trace ---</detail>
    <Exception type="System.Exception">
      <message>Error copying "AcomSubscriber.xds" to "\\ACOM-P40\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P42\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P39\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P41\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P44\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P43\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P47\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P49\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P45\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P48\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P50\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P46\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P51\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password</message>
      <detail>System.Exception: Error copying "AcomSubscriber.xds" to "\\ACOM-P40\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P42\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P39\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P41\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P44\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P43\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P47\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P49\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P45\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P48\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P50\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P46\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password
Error copying "AcomSubscriber.xds" to "\\ACOM-P51\C$\Program files (x86)\Zetron\AcomConsole"; Exception: Logon failure: unknown user name or bad password</detail>
    </Exception>
  </Exception>
</FaultResponse>
// get message from system and store in variable target
rapidxml::xml_document<> doc;
try
{
  doc.parse<0>(target);
}
catch (const std::runtime_error& e)
{
  std::cerr << "Runtime error was: " << e.what() << std::endl;
}
catch (const rapidxml::parse_error& e)
{
  std::cerr << "Parse error was: " << e.what() << std::endl;
  cout << "Trying to parse: " << target << " of size " << strlen(target) << endl;
}
catch (const std::exception& e)
{
  std::cerr << "Error was: " << e.what() << std::endl;
}
catch (...)
{
  std::cerr << "An unknown error occurred." << std::endl;
}

I expected to get the doc variable to have the contents of the xml document and start working my way through it, but I get the parse error.

  • Obviously there is an error in the XML. The `rapidxml::parse_error` tells you what is wrong with the XML, and also *where* in the XML the error is located. So what is the `rapidxml::parse_error` actually telling you? You did not show that information – Remy Lebeau May 14 '19 at 02:54
  • Is `target` a string that you can print to `cout`? Is the xml that you provided from a log in the server or the actual contents of `target`? I copied your xml into a file and it parsed without error. – Jonathon K May 14 '19 at 13:34
  • the xml provided is from the server. The actual error returned by parse was "Parse error was: expected – Mauricio Ramirez May 14 '19 at 15:35
  • If you are catching the exception, you could try getting some context. something like `catch (rapidxml::parse_error& ex) { char where[101]; memset(where, 0, 101); long whereLen = strlen(ex.where()); whereLen = whereLen > 100 ? 100 : whereLen; memcpy(where, ex.where(), whereLen); std::cout << ex.what() < – Jonathon K May 14 '19 at 18:07

1 Answers1

0

I've done some more testing and it appears the XML file is valid and able to be parsed. I created a separate program to test it and rapidxml worked just fine. Looks like something is corrupting the target variable.

  • Make sure you're familiar with RapidXML's string ownership model. It catches a lot of people out. https://stackoverflow.com/questions/2432478/how-to-fix-rapidxml-string-ownership-concerns – Roddy May 16 '19 at 17:14