Prohlížíte obsah nápovědy pro verzi:

Overview

AEM Forms enables form authors to further simplify and enhance the form filling experience by invoking web services from within an adaptive form field. AEM Forms supports web services described in Web Services Description Language (WSDL) 1.1 with Document/literal style and that have SOAP endpoints.

To invoke a web service, you can either create a rule in the visual editor or specify a JavaScript using the guidelib.wsdlUtils.invokeWebService API in the code editor of the rule editor.

This document focuses on writing a JavaScript using the guidelib.wsdlUtils.invokeWebService API to invoke a web service. 

The guidelib.wsdlUtils.invokeWebService API

The guidelib.wsdlUtils.invokeWebService API invokes a web service from within an adaptive form field. The API syntax is as follows:

guidelib.wsdlUtils.invokeWebService (wsdlPath, invokeData, successHandler, faultHandler, callbackData)

The API requires the following parameters.

Parameter Description
wsdlPath HTTP path to the WSDL web service.
invokeData Structure to provide details about the web service operation. See invokeData structure for more information.
successHandler Web service handler to be called on successful invocation of the web service.
faultHandler Web service handler to be called on failed invocation of the web service.
callbackData Data to be made available on calling the successHandler and errorHandler.

The invokeData structure

The invokeData structure in the guidelib.wsdlUtils.invokeWebService API specifies details about the web service operation to be performed. The syntax of the structure is as follows.

var invokeData = {
operationName, 
input, 
inputRoot, 
soapActionURI, 
serviceEndPoint, 
namespace, 
port
}

The invokeData structure specifies the following details about the web service operation.

Parameter Description
operationName Name of the web service operation to be executed.
input Input to the web service operation in JSON format. Ensure that it does not include the input root. The guidelib.wsdlUtils.invokeWebService API uses the operation name as input. If the input root is different from the operation name, use the inputRoot parameter.
inputRoot (optional) Input root, if different from operationName.
soapActionURI (optional) URI for the SOAPAction HTTP header. If it is not present in WSDL, the API downloads the WSDL from the server and uses the value of the port element.
serviceEndPoint (optional) The location property of the soap:address element of the required port. If it is not present in WSDL, the API downloads the WSDL from the server and uses the value of the port element.
namespace (optional) The namespace for the WSDL schema. If it is not present in WSDL, the API downloads the WSDL from the server and uses the value of the port element.
port
(optional)
Name of the port specified in WSDL. If port, soapActionURI, and namespace parameters are not present in WSDL, the API finds the port (SOAP-only) in which this operation is exposed. If there are multiple ports where this operation is implemented, the function fails.

Poznámka:

Some parameters in the invokeData structure are marked optional because it downloads and parses the WSDL to retrieve the required information. However, for better performance of the operation, consider specifying optional parameters.

Example script to invoke a web service

The following example script uses the guidelib.wsdlUtils.invokeWebService API to invoke the getZipInfo web service operation. The operation takes ZIP code as input and returns the matching city and state. If the web service operation fails to find information, an error handler returns the could not get the ZIP information message.  

var wsdlPath = 'http://www.example.com/ZIPInfo?WSDL';
var input = '{"zipCode" : "232423"}';
var invokeData = {};
invokeData.operationName = 'getZipInfo';
invokeData.input = input;
invokeData.soapActionURI = 'http://www.example.com/ZIPInfo';
invokeData.serviceEndPoint = 'http://www.example.com/ZIPInfo.asmx';
invokeData.port = 'ZIPInfoSoap';

successHandle : function (serviceOutput) {
    var outputJSONObj = JSON.parse(serviceOutput);
                // use outputJSONObj["City"]
                // use outputJSONObj["State"]
},

errorHandler : function () {
                window.alert ('could not get the ZIP information');
},

var myData = {'param' : 'value'};
guidelib.wsdlUtils.invokeWebService (wsdlPath, invokeData, successHandler, errorHandler, myData);

Considerations when working with web services

Keep in mind the following considerations when invoking web services from within adaptive forms:

  • You can invoke web services that are written in WSDL 1.1 with Document/literal style and that have SOAP endpoints.
  • Web services that require authentication are currently not supported.
  • Web services operations that use arguments from multiple namespaces are not supported.
  • Do not include the root element in the input structure.  

Tato práce podléhá licenci Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.  Na příspěvky ze služeb Twitter™ a Facebook se nevztahují podmínky licence Creative Commons.

Právní upozornění   |   Zásady ochrany osobních údajů online