XML Issue with Encompass – Unrecognized Response

We do work for several clients that we have developed an API to integrate with Encompass. This allows our clients to offer the ability to accept orders into their web-based application via Encompass. This has opened them up to new possibilities of income.

In testing an upcoming roll-out for a project, Encompass started returning “Unrecognized response from Client Name” errors. The server showed no issues, and the debug capturing that we had turned on offered no support, as no code was failing. The XML looked fine, as far as we could tell.

We installed IEInspector HTTP Analyzer – a great tool to track what data is being sent from your machine and what is returned. Once installed, we started it and started capturing data. We then processed an order through Encompass and checked the results. XML WAS returning to Encompass, and it looked fine. I then quickly glanced at the resulting XML returned from Encompass (saved to C:\Users\Joel\AppData\Local\Temp\ADVOE_LastOrderRep.xml for our product – this will vary, depending on your product) and it “looked” blank, or empty. It wasn’t. The XML was in the file, but the first three (3) characters were ???. I saw this by opening it in IE and doing Ctrl + U to see the source.

My immediate idea was BOM. We had had an issue with this before. So we debugged and determined the file we were originally working in didn’t have it, so all of things we tried on the XML to strip it failed. It turned out the BOM was in an included file at the top of the script. To determine that, we did the following (in the web root of the server in question):

# grep -rl $'\xEF\xBB\xBF' .

This gave us a list of files, mostly images or irrelevant files, but one in the list DID have the BOM and was being included in our script. To fix the file in question, we simply did the following:

# vi classes/File.php
:set nobomb

We then tested again, and Encompass was able to view the XML fine and all was well with the world!

Posted in PHP Tagged with: , ,