IRIS Creating Publisher API
IRIS Creating Publisher API
mb-api-publish-v1.0.0-swagger.json
Modified JSON File:
Step 2: Check the correctness of that swagger JSON via the open-source swagger
editor, the URL of which is given below. If any structural errors are thrown, resolve it.
htps://editor-next.swagger.io/
Step 3: Import this swagger defini�on in workbench using the “Import API
defini�on” op�on and download the publisher zip file.
MD Shibli Mollah
T24 Technical Analyst
Download the zip file.
Step 4: Create a maven project with archetype-service catalog and import the zip file
downloaded in the previous step.
--------------------------------------------------------------------------------------------------------------------------------------
Step 5: Navigate to publisherProject - Published-AcBal
<<publisherProject>>\src\main\java\ com.api.service
package directory, right click and select New -> Java -> Class and enter the
class name as <<AnyRelevantName>>Mapper and add the interface named
“Processor” under Interfaces.
MD Shibli Mollah
T24 Technical Analyst
MD Shibli Mollah
T24 Technical Analyst
Step 6: The mapper class will be generated as shown below.
The process() method in the mapper must have the code logic to transform the provider API
to publisher API and vice versa.
The code logic must be in such a way that the fields present in the JSON response body of
the provider API are mapped to the fields defined in the swagger of published API using the
published API swagger classes generated.
MD Shibli Mollah
T24 Technical Analyst
JSONObject jsonHeader = jsonObject.getJSONObject("header");
String updateResponse = null;
if (HttpResponseCode.equals("200")) {
JSONObject jsonBody =
jsonObject.getJSONArray("body").getJSONObject(0);
try {
responseCode = jsonBody.get("response").toString();
accountNo = jsonBody.get("accountId").toString();
alternateAccountNo = jsonBody.get("accountIBAN").toString();
currency = jsonBody.get("currency").toString();
balance = jsonBody.get("availableBalance").toString();
} catch (Exception e) {}
jsonBody.remove("accountId");
jsonBody.remove("accountIBAN");
// jsonBody.remove("currency");
jsonBody.remove("availableBalance");
jsonBody.put("accountNo", accountNo);
jsonBody.put("alternateAccountNo", alternateAccountNo);
jsonBody.put("balance", balance);
jsonHeader.remove("audit");
jsonHeader.remove("page_start");
jsonHeader.remove("page_token");
jsonHeader.remove("total_size");
jsonHeader.remove("page_size");
jsonHeader.remove("status");
jsonHeader.put("statusCode", responseCode);
updateResponse = "{\"header\":" + jsonHeader + ",\"body\":" + jsonBody
+ "}";
}
ObjectMapper om = JSONHelper.createObjectMapper();
JsonNode modifiedResponse = om.readTree(updateResponse);
in.setBody(modifiedResponse);
}
party-v1.0.0-published-myacbal-service-v1.0.0.xml party-v1.0.0-published-myacbal-service-v1.0.0.xml
Special Note: We must redirect the URI of the other versions of the service xml’s of
the Publisher API by changing like this, otherwise war file deployment will be failed.
<route id="direct-vm.party-v1.0.0.v1.0.getAcBal">
<from uri="direct-vm:party-v1.0.0.v1.0.getAcBal"/>
<!-- OWN PUBLISHER API Uri -->
<to uri="direct-vm:party-v1.0.0.v1.0.0.getAcBal"/>
</route>
MD Shibli Mollah
T24 Technical Analyst
party-v1.0.0-published-myacbal-service-v1.0.xml party-v1.0.0-published-myacbal-service-v1.xml
Published-AcBal-0.0.1-SNAPSHOT.jar Published-AcBal-0.0.1-SNAPSHOT.jar
MD Shibli Mollah
T24 Technical Analyst
Step 8: Include the publisher API and provider API project(s) dependency in
the container project’s pom.xml and perform maven install.
Step 9: Create a new bean with any relevant name for “id” atribute in
applica�onContext.xml of the container project for the mapper class created.
Enable Basic Auth/JWT required.
<!-- Response mapper added -->
<bean id="UpdateAcBalInfo" class="com.api.service.UpdateAcBalInfo">
</bean>
MD Shibli Mollah
T24 Technical Analyst
SAVE it.
PublishedAcBalContainer.war PublishedAcBalContainer.war
Step 10: Deploy the war in applica�on server (or) jety server.
Step 11: APIs can now be accessed with structure of published API JSON and
the corresponding response is now formed as per requirement.
MD Shibli Mollah
T24 Technical Analyst
Below screenshots show the JSON requests and responses for the examples
explained in this document.
AcBalanceContainer_response.json
MD Shibli Mollah
T24 Technical Analyst
UpdatedAcBalanceContainer_response.json
A�er changing the Java Code to meet our expecta�on.
UpdateAcBalInfo.java
MD Shibli Mollah
T24 Technical Analyst
Final_Published_response.json
MD Shibli Mollah
T24 Technical Analyst