0
votes

First time using Mirth. We will be communicating with an outside service. Part of the SOAP Envelope in the SOAP message is userId and passWord. In addition to that we need to basically perform a hash that creates a unique token each time we call the service. I need that part of the XML payload to come from a function. Is there a way for a piece of the data to be inserted into the SOAP Envelope that is the result of a JavaScript function call?

1

1 Answers

0
votes

First of all you need to use the Web Service Sender Connector Type. In this example I have chosen an online weather web service.

enter image description here

Paste the WSLD URL (orange) and click the "Get Operations" button (red)

After selecting the correct service, click the "Generate Envelope" button (red) which will make a soap stub for you. Something like this, where you can use variables like this ${variableName}

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
   <soapenv:Header/>
   <soapenv:Body>
      <web:GetCitiesByCountry>
         <!--Optional:-->
         <web:CountryName>${myGeneratedCountryName}</web:CountryName>
      </web:GetCitiesByCountry>
   </soapenv:Body>
</soapenv:Envelope>

For the variable to be populated with your calculated value you need to use, for instance, a javascript transformer.

Create a new Destination and edit the tranformer.

enter image description here

And then you can use javascript to calculate your value.

enter image description here

Last line is used to make the variable and its content available for the Web Service Sender. It works like a java Map

$co('myGeneratedCountryName',country);

However there are other methods, code templates for instance. If you are new to Mirth Connect I recommend you reading the Mirth Connect User Guide which covers this use case and many others.