How to implement Injector Service (Service Contract) using ReST
Here is the Rest service contract detail:
-
Keep the path as Injector/inject.
@Path("/injector")
-
Use POST for this service. As the input message object itself has identifier (message type- CRE/MOD) they don't need to use the PUT/PATCH. they can use message type to build the implementation logic.
@POST @Path("/inject") @Consumes({MediaType.APPLICATION_XML})
-
The input would be MediaType.APPLICATION_XML and the structure would be 'ApplicationMessage' object. (file attached for reference).
<xs:element name="ApplicationMessage"> <xs:complexType> <xs:sequence> <xs:element name="family" type="string25"/> <xs:element name="type" type="string30"/> <xs:element name="businessObjectId" type="string255" minOccurs="0"/> <xs:element ref="ApplicationMessageRoutingInfo" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="payloadXml" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
-
Customer can utilize the payload.properties file for validation of message family and type.
-
Return type should be JSON, see below example:
String message = "{\"message\": \"Inject successful.\"}"; return Response.ok(message, MediaType.APPLICATION_JSON).build();
-
For exception response customer needs to follow the structure of exceptionVO.