zaus / forms-3rdparty-xpost

Converts external submission from [Forms: 3rdparty Integration](http://wordpress.org/plugins/forms-3rdparty-integration/) plugin to XML post; optionally can add custom headers (to allow SOAP submissions).
4 stars 2 forks source link

How can I remove <?xml version="1.0"?> string? It's causing submission to fail #20

Closed tmaaz closed 8 years ago

tmaaz commented 8 years ago

I have a client who needs form submissions routed to a LinkTrust server -- however, the 3rd party integration solution seems to wrap the resulting data in an "array" tag when sending, which is causing the submission to fault out when it gets to the remote server, because it doesn't understand the array tag.

I installed your xpost tool, figuring XML was the easiest way to circumvent this issue... however, now I'm running into a similar issue: the xpost tool outputs all the data exactly correct (including my injected wrapper tag around the rest of the XML content)... but it's also injecting an opening string of code that reads <?xml version="1.0"?> into the post, which is causing the LinkTrust server to throw an error -- the server thinks the rest of the fields are missing and/or unreadable, because it can't get past this unexpected snippet of code. (If I remove this <?xml version="1.0"?> string and manually send the rest of the XML as-is, the server accepts it without a hitch... so it's definitely getting snagged on that one bit of code).

How can I remove that <?xml version="1.0"?> code? I dug through the php line-by-line, but I'm nowhere near an expert, and I can't figure out what is creating that line of code, or where it's coming from. I did a little php research and tried to inject a "str_replace" into the code, to replace <?xml version="1.0"?> with nothing... but either it's not working, I'm not doing it correctly, or maybe I'm not putting it in the right place or something -- the end result is ignoring me, and the <?xml version="1.0"?> line of code is still there.

I'm so close to having this work, but that one little line of code is keeping me from crossing the finish line -- can you please tell me how to make that string disappear from what's sent to the server? (When you reply, please assume that I only know just enough about php to be slightly dangerous to myself and everyone around me.) =)

tmaaz commented 8 years ago

OK, this is not the proper way to do this (because it will break if the plugin is updated), but in the php file of the plugin, at about line 168, adding

$args = str_replace("<?xml version=\"1.0\"?>", '', $args);

directly before the variable $args is returned will remove the offending line of code.

Maybe this can be a user option within the interface on the next update, to strip the prolog / header? I can't imagine I'm the only person who's ever run into this.