web stats
Remplace > < Webservice - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 11-13-2019, 02:18 AM
mberges mberges is online now
OBX.1 Kenobi
Join Date: Jan 2018
Posts: 45
mberges is on a distinguished road
Default Remplace > < Webservice

I need the answer that a webservice sends me to remove the characters by <> I created this script in the response transform, but I can't change the symbols.

<soap:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body xmlns="http://tempuri.org/">
<SingleCallResult>&lt;?xml version="1.0"?&gt;&lt;ACK xmlns="urn:hl7-org:v2xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;MSH&gt;&lt;MSH.1&gt;|&lt;/MSH.1&gt;&lt;MSH.2&gt;^~\&amp;amp;&lt;/MSH.2&gt;&lt;MSH.3&gt;&lt;HD.1&gt;&lt;/HD.1&gt;&lt;/MSH.3&gt;&lt;MSH.5&gt;&lt;HD.1&gt&lt;/HD.1&gt;&lt;/MSH.5&gt;&lt;MSH.7&gt;&lt;TS.1&gt;20191113110503&l t;/TS.1&gt;&lt;/MSH.7&gt;&lt;MSH.8&gt;usr&lt;/MSH.8&gt;&lt;MSH.9&gt;&lt;MSG.1&gt;ACK&lt;/MSG.1&gt;&lt;MSG.2&gt;O01&lt;/MSG.2&gt;&lt;/MSH.9&gt;&lt;MSH.10&gt;986b5a1b-3291-486e-98f4-98eda22cefcb110503&lt;/MSH.10&gt;&lt;/MSH&gt;&lt;MSA&gt;&lt;MSA.1&gt;AE&lt;/MSA.1&gt;&lt;MSA.2&gt;986b5a1b-3291-486e-98f4-98eda22cefcb&lt;/MSA.2&gt;&lt;/MSA&gt;&lt;ERR&gt;&lt;ERR.3&gt;&lt;CWE.1&gt;36&lt;/CWE.1&gt;&lt;/ERR.3&gt;&lt;ERR.4&gt;E&lt;/ERR.4&gt;&lt;ERR.7&gt;[Parser]

This is the script that I am using

var mensaje = response.getMessage();

var me = mensaje.replaceAll('&lt;', '<').replaceAll ('&gt;', '>');

return me;
Reply With Quote
Old 11-13-2019, 10:49 AM
agermano agermano is offline
Mirth Guru
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,106
agermano is on a distinguished road

The return value from a transformer isn't used. If you want to do string replacement like that just do:
var mensaje = response.getMessage();
msg = mensaje.replaceAll('&lt;', '<').replaceAll ('&gt;', '>');
Then set your outbound type to Raw since msg is now a String.

If you want to keep it XML straight through, this should work:
var singleCallResult = msg.*::Body.*::SingleCallResponse.*::SingleCallResult;
singleCallResult.setChildren(new XML(singleCallResult.toString()))
Reply With Quote
Old 11-14-2019, 05:49 AM
cory_cole cory_cole is offline
Mirth Guru
Join Date: Mar 2012
Posts: 1,348
cory_cole is on a distinguished road

If you use the replace all you may need to include the following line. Replace all in a Java function and not a JavaScript function....

msg = java.lang.String(msg);
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 01:22 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation