web stats
Remplace > < Webservice - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2019, 02:18 AM
mberges mberges is offline
OBX.1 Kenobi
 
Join Date: Jan 2018
Posts: 44
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-ENV:Header/>
<soap:Body xmlns="http://tempuri.org/">
<SingleCallResponse>
<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]
&lt;/ERR.7&gt;&lt;/ERR&gt;&lt;/ACK&gt;</SingleCallResult>
</SingleCallResponse>
</soap:Body>
</soap:Envelope>


This is the script that I am using

var mensaje = response.getMessage();

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


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

The return value from a transformer isn't used. If you want to do string replacement like that just do:
Code:
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:
Code:
var singleCallResult = msg.*::Body.*::SingleCallResponse.*::SingleCallResult;
singleCallResult.setChildren(new XML(singleCallResult.toString()))
Reply With Quote
  #3  
Old 11-14-2019, 05:49 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,310
cory_cole is on a distinguished road
Default

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
Reply

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 07:18 AM.


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