How to implement Injector Service (Service Contract) using ReST

Here is the Rest service contract detail:

  1. Keep the path as Injector/inject.

    @Path("/injector")
    
  2. 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})
    
  3. 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>
    
  4. Customer can utilize the payload.properties file for validation of message family and type.

  5. Return type should be JSON, see below example:

    String message = "{\"message\": \"Inject successful.\"}";
    return Response.ok(message, MediaType.APPLICATION_JSON).build();
    
  6. For exception response customer needs to follow the structure of exceptionVO.