For some advanced Attribute forms, it may be required to collect information from an external server of send information to it.
Normally, web calls can be done using AJAX in the CustomFormExtension.js file. However, because of security reasons, most browsers will not let you call an External server with AJAX.
WebCenter 16 introduces the possibility to go to an external system indirectly using the External Web Connections extensions. This article will show an example of how an external call can be made.
Follow these steps:
Add a function that makes the Web Call. The example given below will allow the Attribute Category to make a SOAP call. Things to keep in mind for this function:
Make a call to GetExternalWebInfo.jspand add the needed parameters in FormData object.
Add the target of the call by refering to an existing External Web Connection, using the parameter ExternalWebConfigName.
Add correct request method (GET vs POST) using the parameter requestmethod. GET is the default option.
If extra request headers are needed (e.g.: SOAPAction for SOAP calls), add them using the parameter requestheader. There can be multiple request headers and they should be added in the format <headername>:<headervalue>.
If needed, add a request body using parameter requestbody.
if needed, parameters can be added to the URL dynamically, using requestparams.
Define the response type using the parameter responsetype, which should be a valid MIME type, e.g.: application/json, text/html. SOAP example
Make the AJAX call synchronous by adding a parameter async:false. This will wait until an answer returns until it continues. Side effect however, is that the browser will be blocked while waiting. This is not recommended for slow calls.
Add some logic that stores the returned information when it returned and trigger a new button click to a button that can process the obtained information. For example: