Table of Contents

Search

  1. Preface
  2. Introduction to Business Entity Services
  3. EJB Business Entity Service Calls
  4. REST Business Entity Service Calls
  5. REST APIs for Data Director
  6. SOAP Business Entity Service Calls
  7. Cross-reference Records and BVT Calculations Services
  8. Supporting Corporate Linkage Service
  9. External Calls to Cleanse, Analyze, and Transform Data
  10. Appendix A: Using REST APIs to Add Records
  11. Appendix B: Using REST APIs to Upload Files
  12. Appendix C: Using REST APIs to Manage Reports

Sample External Call

Sample External Call

To learn how to create an external call, review the BESExternalCall sample that is available in the Resource Kit. The following sections include information about the required steps to create and test the BESExternalCall sample.
The BESExternalCall sample implements the simplest foundation for a successful external call setup.
The BESExternalCall sample has the following code structure:
  • CustomLogic implementations in the ValidatePerson.java and MergePerson.java files
  • CustomLogicFactory implementation in the CustomLogicFactorImpl.java file
  • WebService implementation in the CustomLogicService.java file

CustomLogic implementations in the ValidatePerson.java and MergePerson.java files

CustomLogic implementations for an external call include the custom business logic, such as additional data validation and manipulation.
CustomLogic implementations must include a com.informatica.mdm.spi.externalcall.CustomLogic interface, which is available in the mdm-spi.jar file. This interface exposes the process method where you can define custom business logic. The following ValidatePerson.java class code is a sample:
public class ValidatePerson implements CustomLogic { private CompositeServiceClient besClient; private CallContext callContext; public ValidatePerson(CompositeServiceClient besClient, CallContext callContext) { this.besClient = besClient; this.callContext = callContext; } @Override public DataObject process(HelperContext helperContext, DataObject inputSdo, Map < String, Object > inParams, Map < String, Object > outParams) throws StepException { try { List < ValidationError > errorList = new ArrayList < > (); DataFactory dataFactory = helperContext.getDataFactory(); // Ensure that the Person SDO has at least one Address item List<?> list = inputSdo.getList("Person/Addresses/item"); if ((list == null) || list.isEmpty()) { String personId = inputSdo.getString("Person/rowidObject"); if(personId != null) { // Verify if an address already exists DataObject readEntity = dataFactory.create(ReadEntity.class); DataObject personFilter = readEntity.createDataObject("parameters").createDataObject("coFilter").createDataObject("object"); personFilter.setString("name", "Person"); personFilter.createDataObject("key").setString("rowid", personId); DataObject addressFilter = personFilter.createDataObject("object"); addressFilter.setString("name", "Addresses"); addressFilter.createDataObject("pager").setInt("recordsToReturn", 1); DataObject readEntityReturn = besClient.process(callContext, readEntity); List existingList = readEntityReturn.getList("object/Person/Addresses/item"); if (existingList == null || existingList.isEmpty()) { errorList.add(createValidationError(dataFactory, "CUSTOM-00001", "You must enter at least one Address.", "Person.Addresses")); }

CustomLogicFactory implementation in the CustomLogicFactorImpl.java file

A CustomLogicFactory implementation provides the CustomLogic instances to run at the expected phase, run for the target business entity, or both.
A CustomLogicFactory implementation must include a com.informatica.mdm.spi.externalcall CustomLogicFactory interface, which is available in the mdm-spi.jar file. This interface exposes the create method, which the external call request invokes at early stages. The logic expected in this method filters and directs the external call request to the expected custom logic implementation. The following CustomLogicFactoryImpl.java code is a sample:
public class CustomLogicFactoryImpl implements CustomLogicFactory { public static final String PERSON = "Person"; private static final CustomLogic EMPTY_LOGIC = new EmptyLogic(); private CompositeServiceClient besClient; public CustomLogicFactoryImpl(CompositeServiceClient besClient) { this.besClient = besClient; } @Override public CustomLogic create(ExternalCallRequest externalCallRequest, CallContext callContext) throws StepException { // Interest is in the Person business entity. The logic can handle a few service phases. Trigger trigger = externalCallRequest.getTrigger(); String businessEntity = trigger.getBusinessEntity(); ServicePhase phase = trigger.getServicePhase(); switch (phase) { case WRITE_CO_BEFORE_VALIDATE: if (PERSON.equals(businessEntity)) { return new ValidatePerson(besClient, callContext); } break; case PREVIEW_MERGE_CO_BEFORE_EVERYTHING: case MERGE_CO_BEFORE_EVERYTHING: if (PERSON.equals(businessEntity)) { return new MergePerson(); } break; default: // } return EMPTY_LOGIC; // This one does nothing }
A CustomLogicFactory implementation can include the following create method parameters:
externalCallRequest
An instance of the request that represents the external call as defined in the bes-external-call.xsd file.
callContext
An instance of the composite service context that the CompositeServiceClient requests use in custom logic implementations.

WebService implementation in the CustomLogicService.java file

A WebService implementation exposes the complete service that an external call invokes and is the entry point of the external call flow.
The following CustomLogicService.java sample code implements the web service that the bes-external-call.xsd file defines based on the native WebService API from Java:
/** * Web service implementation. * It must accept a {urn:bes-external-call.informatica.mdm}ExternalCallRequest as an operation input * and return a {urn:bes-external-call.informatica.mdm}ExternalCallResponse as output. */ @WebServiceProvider( targetNamespace = "http://cs.sample.mdm.informatica.com/", serviceName = "CustomLogicService", portName = "CustomLogicServicePort", wsdlLocation = "WEB-INF/wsdl/custom-logic-service.wsdl" ) @ServiceMode(Mode.PAYLOAD) public class CustomLogicService implements Provider<Source> { @Override public Source invoke(Source request) { CompositeServiceClient compositeServiceClient = createCompositeServiceClient(); CustomLogicFactory customLogicFactory = new CustomLogicFactoryImpl(compositeServiceClient); String appName = "<trusted_user>"; // replace with proper application user name // Create a processor instance and let the instance perform the job. // Provide a custom logic factory implementation. ExternalCallProcessor externalCallProcessor = new ExternalCallProcessor(compositeServiceClient, appName, customLogicFactory); return externalCallProcessor.invoke(request); }
The invoke method of the ExternalCallProcessor instance handles the incoming request.
The ExternalCallProcessor instance relies on a trusted application user. For more information about trusted application users, see the
Multidomain MDM Security Guide
.

BESExternalCall example

The BESExternalCall external call to the web service can perform the following actions:
  • When creating or updating a person, the call validates whether the person has at least one address. If the validation fails, the call returns a customized error message.
  • When generating a preview of merged records, the call does not merge telephone numbers.
  • When merging records, the call does not merge telephone numbers.
The following table describes the files and the file locations that support the BESExternalCall example:
File Name
Description
Location
bes-external-call.xsd
Defines the request and response types for all external calls. An external web service operation must use the request and response types for the input and output elements.
<MDM installation directory>/hub/server/lib/mdm-spi.jar
custom-logic-service.wsdl
WSDL file for the example web service. Defines the external services, operations, methods, and data types that the service methods exchange.
<MDM installation directory>/hub/resourcekit/samples/BESExternalCall/source/resources/webapp/WEB-INF/wsdl/
ValidatePerson.java
and
MergePerson.java
Examples of custom validate and merge operations that run with the example web service.
This example uses .java files, but your external web service might require a different coding standard.
<MDM installation directory>/hub/resourcekit/samples/BESExternalCall/source/java/
build.xml
Builds the
bes-external-call.ear
file.
<MDM installation directory>/hub/resourcekit/samples/BESExternalCall/
bes-external-call.ear
The
.ear
file that you deploy to the application server to run this example.
<MDM installation directory>/hub/resourcekit/samples/BESExternalCall/build/

0 COMMENTS

We’d like to hear from you!