Error with output soap response from CRMScript

Hi there.

I'm trying to output soap response from CRMScript but get an Error 502 - Web server received an invalid response while acting as a gateway or proxy server.

i've added these headers to my crmscript:

Map _headers;
_headers.insert("Content-Type", "application/soap+xml; charset=utf-8"); 
_headers.insert("Access-Control-Allow-Methods","POST");
 
String h;
for (_headers.first(); !_headers.eof(); _headers.next())
h += _headers.getKey() + ": " + _headers.getVal() + "\n";

setParserVariable("ej.headers", h); 

When i try to call the script in a new window (Both via customer.fcgi safeParse and blogic.fcgi)

I get a 502 error:

If i don't change the header it outputs just fine, and valid xml - but with a wrong content-type of course.

 

Any help or tips to what could be wrong? Running the script inside the editor with the headers on works just fine too :)

 

Thanks

Moderator: Please create sensible topic headers 

RE: Error with output soap response from CRMScript

Hi,

Have you tried to change Content-Type to "application/xml"?

By: Michel Krohn-Dale 23 Sep 2020

RE: Error with output soap response from CRMScript

Hi Dennis, 

could you try this? This works here.

%EJSCRIPT_START%
<%
#setLanguageLevel 3;
#include "lib-http";

AddHttpHeader("Content-Type", "application/soap+xml; charset=utf-8");
AddHttpHeader("Access-Control-Allow-Methods", "POST");

String xml = "<hi>there</hi>";

return Ok(xml);

%>
%EJSCRIPT_END%
By: Frode Lillerud 23 Sep 2020