Sidebar

Can I override the URL on a Rest Web Service call in QIE?

+1 vote
863 views
asked Dec 21, 2017 by brandon-w-8204 (33,860 points)
I need to change the URL called dynamically in code. Can I override  the connection information?

1 Answer

+1 vote

The qie.callRESTWebService function includes multiple parameters. The first parameter passed is the WS connection name. The second parameter passed is the URL. To call another endpoint, just pass a different URL to that call. Keep in mind, the SSL configuration (selected certificates, client authentication etc) configured in the WS connection will be used with the URL passed in. So, if the SSL configuration is different for the over ridden  URL, a different WS connection is required.

 

Inline image 1

 

Sample Code:

//Code created by the mapping function using what is on the ws connection
var parameterMap = qie.newParameterMap();
var urlTemplate = qie.evaluateTemplate("https://immun.dhec.sc.gov/HL7Service/MessageService.svc");
var content = qie.evaluateTemplate("<root></root>", false);
var value = qie.callRESTWebService(
"iis test1",
urlTemplate,
"POST",
content,
"application/xml",
parameterMap,
60000);

// Call a different url overriding what is on the ws connection
var parameterMap = qie.newParameterMap();
var urlTemplate = qie.evaluateTemplate("https://some.web.service:8300/XMLService");
var content = qie.evaluateTemplate("<root></root>", false);
var value = qie.callRESTWebService(
"iis test1",
urlTemplate,
"POST",
content,
"application/xml",
parameterMap,
60000);

Using the standard mappings to setup your code:

You can also build the code like what you see above using the mapping function dialog. You setup your webservice like you see below and then copy the code in the script window or click on the "Customize Script" checkbox.

Inline image 2

answered Dec 21, 2017 by brandon-w-8204 (33,860 points)
...