| Oracle® Retail Integration Cloud Service Implementation Guide–Concepts Release 22.1.201.0 F56230-01 |
|
![]() Previous |
![]() Next |
A sample of the REST publisher client code is below:
//Import required classes
import com.oracle.retail.integration.base.bo.fulfilorddesc.v1.*
import com.oracle.retail.integration.payload.Payload
import com.retek.rib.domain.payload.PayloadFactory
import com.oracle.retail.integration.rib.applicationmessages.v1.ApplicationMessage;
import com.oracle.retail.integration.rib.applicationmessages.v1.ApplicationMessages;
//Create new instance of your FulfilOrdDesc object and populate it.
FulfilOrdDesc fulfilOrdDesc = new FulfilOrdDesc()
fulfilOrdDesc.setCustomerOrderNo(123)
//Get a string version of the payload
String payloadXml = PayloadFactory.marshalPayload(fulfilOrdDesc)
//Prepare the header message section
ApplicationMessages ams = new ApplicationMessages();
ApplicationMessage am = new ApplicationMessage();
am.setFamily("FULFILORD");
am.setType("FULFILORDPOCRE");
am.setBusinessObjectId("abc"); //optional
//Set the payload xml into the message
am.setPayloadXml(payloadXml);
ams.getApplicationMessage().add(am);
//Call rest url with ams
String ribPublisherRestUrl = "http://<host>:<port>/rib-oms-services-web/resources/publisher/publish"
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(ribPublisherRestUrl);
String userName = "ribadmin";
char[] password = "ribadmin1";
String usernameAndPassword = userName + ":" + new String(password);
String authorizationHeaderValue = "Basic " + java.util.Base64.getEncoder().encodeToString( usernameAndPassword.getBytes() );
Invocation.Builder invocationBuilder = webTarget.request().header("Authorization", authorizationHeaderValue);
Response response = invocationBuilder.post(Entity.entity(ams, MediaType.APPLICATION_XML));
log.debug("Publish call response(" + response + ").");
Q1. Is using PayloadFactory required? OR can I use standard JAXB?
A1. It's recommended that you use the PaloadFactory as it handles the html encoding that's required while including the payload in the RIBMessages envelope. All RIB connected apps use the API and we maintain it so that if there are any fixes that can be distributed. It also takes care of validation etc and when you're using RBO's it's best to use this class so that the family/type bind to the right JAXB beans
Q2. Can we send multiple ApplicationMessage as part of ApplicationMessages?
A2. Yes, multiple AM's are typically published together each AM corresponds to a RIBMessage node and AMS corresponds to RIBMessages envelope.
Q3. How do I know if my message made it successfully?
A3. You get HTTP status 200 OK when Publish is successful. The client receives a JSON string with a "Message" on it saying "Publish done".
Q4. Where can see the RIB logs for the messages I published?
A4. You can login to RIB-<app> admin GUI and look at the logs as you test to see the messages, errors, and so on. See below.
