A Appendix - Sample Files

Sample Application.wadl File

<?xml version="1.0" encoding="ISO-8859-1"?>
<ns0:application xmlns:ns0="http://wadl.dev.java.net/2009/02">
  <ns0:doc ns1:generatedBy="Jersey: 2.22.4 2016-11-30 13:33:53" xmlns:ns1="http://jersey.java.net/"/>
  <ns0:doc ns2:hint="This is simplified WADL with user and core resources only. To get full WADL with extended resources use the query parameter detail. Link: http://abc.us.oracle.com:8003/rib-injector-services-web/resources/application.wadl?detail=true" xmlns:ns2="http://jersey.java.net/"/>
  <ns0:grammars>
    <ns0:include href="application.wadl/xsd0.xsd">
      <ns0:doc title="Generated" xml:lang="en"/>
    </ns0:include>
  </ns0:grammars>
  <ns0:resources base="http://abc.us.oracle.com:8003/rib-injector-services-web/resources/">
    <ns0:resource path="discover">
      <ns0:method id="discoverAllResources" name="GET">
        <ns0:response>
          <ns0:representation mediaType="application/json"/>
        </ns0:response>
      </ns0:method>
    </ns0:resource>
    <ns0:resource path="/injector">
      <ns0:resource path="/inject">
        <ns0:method id="injectMessage" name="POST">
          <ns0:request>
            <ns0:representation mediaType="application/xml" element="ns3:ApplicationMessage" xmlns:ns3="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1"/>
          </ns0:request>
          <ns0:response>
            <ns0:representation mediaType="*/*"/>
          </ns0:response>
        </ns0:method>
      </ns0:resource>
      <ns0:resource path="/ping">
        <ns0:method id="ping" name="GET">
          <ns0:request>
            <ns0:param name="pingMessage" default="hello" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" style="query"/>
          </ns0:request>
          <ns0:response>
            <ns0:representation mediaType="application/json"/>
          </ns0:response>
        </ns0:method>
      </ns0:resource>
    </ns0:resource>
  </ns0:resources>
</ns0:application>

Sample Resource Class

package com.oracle.retail.rib.integration.services.applicationmessageinjector;
 
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.oracle.retail.integration.rib.applicationmessages.v1.*;
import com.retek.rib.binding.exception.InjectorException;
import com.retek.rib.binding.injector.Injector;
import com.retek.rib.binding.injector.InjectorFactory;
import com.retek.rib.domain.payload.PayloadFactory;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.oracle.retail.integration.payload.Payload;
 
@Stateless
@Path("/injector")
 
public class ApplicationMessageInjectorResource {
 
    private static Log LOG =
            LogFactory.getLog(ApplicationMessageInjectorResource.class);
    
    @GET
    @Path("/ping")
    @Produces({MediaType.APPLICATION_JSON})
    public Response ping(@DefaultValue("hello") @QueryParam("pingMessage") String pingMessage){
        String message = "{\"message\": \"Got " + pingMessage + " from server.\"}";
        return Response.ok(message, MediaType.APPLICATION_JSON).build();
    }
    
    @POST
    @Path("/inject")
    @Consumes({MediaType.APPLICATION_XML})
    public Response injectMessage(ApplicationMessage applicationMessage) throws InjectorException{
        
        verifyNotNull(applicationMessage, "applicationMessage");
        
        
        invokeInjectForMessageType(applicationMessage.getFamily(), applicationMessage.getType(), applicationMessage.getBusinessObjectId(), applicationMessage.getPayloadXml());        
        
        String message = "{\"message\": \"Inject successful.\"}";
        return Response.ok(message, MediaType.APPLICATION_JSON).build();   
    }
    
    
    private void invokeInjectForMessageType(String family, String messageType, String businessObjectId, String retailPayload)throws InjectorException{
        
        try {
            
            verifyNotNull(family, "family");
            verifyNotNull(messageType, "messageType");
            verifyNotNull(retailPayload, "retailPayload");
            
            Payload payload = PayloadFactory.unmarshalPayload(family, messageType, retailPayload);
 
            Injector injector = InjectorFactory.getInstance().getInjector(
      ??             family, messageType);
            if (injector == null) {
                final String eMsg = "Unknown message"
                    + " family/type: " + family + "/" + messageType;
                LOG.error(eMsg);
                throw new InjectorException(eMsg);
                
            }
            if(LOG.isDebugEnabled()){
                LOG.debug("Received inject call for family("+family+") type("+messageType+") businessObjectId("+businessObjectId+") with payload:\n" + payload.toString());
            }
            
            injector.inject(messageType, businessObjectId, payload);
            LOG.debug("Inject call for family("+family+") type("+messageType+") businessObjectId("+businessObjectId+") return.");
            
  ??     } catch (InjectorException e) {
            final String eMsg = "Exception calling inject.";
            LOG.error(eMsg, e);
            throw e;
        }catch (Exception re) {
            final String eMsg = "Exception calling inject.";
            LOG.error(eMsg, re);
            throw new RuntimeException(eMsg, re);
        }
        
    }
    
    private void verifyNotNull(Object field, String fieldName){
      if(field == null){
        final String eMsg = fieldName + " cannot be null.";
        LOG.error(eMsg);
        throw new IllegalArgumentException(eMsg);
      }
    }
    
}

ApplicationMessages.xsd

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1"
           xmlns:rib="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           jaxb:extensionBindingPrefixes="xjc"
           jaxb:version="2.0"
           targetNamespace="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1"
           elementFormDefault="qualified" attributeFormDefault="unqualified">
    
    <xs:annotation>
        <xs:appinfo>
            
            <jaxb:globalBindings
                fixedAttributeAsConstantProperty="false"
                choiceContentProperty="true"
                enableFailFastCheck="true"
                generateIsSetMethod="true"
                enableValidation="true"> 
                <!--xjc:javaType name="java.util.Calendar"
                               xmlType="xs:dateTime" 
                               adapter="com.oracle.retail.integration.rib.rib_integration_runtime_info.datatypeadapter.CalendarAdapter"/ -->
                <jaxb:serializable uid="1"/>
            </jaxb:globalBindings>
            
            <!--jaxb:schemaBindings>
                <jaxb:package name="com.oracle.retail.integration.rib.ribintegrationruntimeinfo" />
            </jaxb:schemaBindings-->
        </xs:appinfo>
    </xs:annotation> 
    
    <xs:element name="ApplicationMessages">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="ApplicationMessage" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <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>
    
    <xs:element name="ApplicationMessageRoutingInfo">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="string25"/>
                <xs:element name="value" type="string25"/>
                <xs:element ref="ApplicationMessageRoutingInfoDetail" minOccurs="0" maxOccurs="2"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="ApplicationMessageRoutingInfoDetail">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="string25"/>
                <xs:element name="value" type="string300"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
  <xs:simpleType name="string255">
    <xs:restriction base="xs:string">
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
 
  <xs:simpleType name="string25">
 
   <xs:restriction base="xs:string">
      <xs:maxLength value="25" />
    </xs:restriction>
  </xs:simpleType>
 
  <xs:simpleType name="string30">
    <xs:restriction base="xs:string">
      <xs:maxLength value="30" />
    </xs:restriction>
  </xs:simpleType>
    
    <xs:simpleType name="string300">
    <xs:restriction base="xs:string">
      <xs:maxLength value="300" />
    </xs:restriction>
  </xs:simpleType>
    
     
</xs:schema>

payload.properties

payload.properties

ASNIN.ASNINCRE=com.oracle.retail.integration.base.bo.asnindesc.v1.ASNInDesc
ASNIN.ASNINDEL=com.oracle.retail.integration.base.bo.asninref.v1.ASNInRef
ASNIN.ASNINMOD=com.oracle.retail.integration.base.bo.asnindesc.v1.ASNInDesc
 
WH.WHCRE=com.oracle.retail.integration.base.bo.whdesc.v1.WHDesc
WH.WHDEL=com.oracle.retail.integration.base.bo.whref.v1.WHRef
WH.WHMOD=com.oracle.retail.integration.base.bo.whdesc.v1.WHDesc

Sample Request/Response for ReST Injector Service

Table A-1 Sample Request/Response for ReST Injector Service

End Point Method Media Type User/ Password Request.xml Response Comments

http://localhost:7001/rib-injector-services-web/resources/injector/inject

POST

application/xml

Request are xml only and response are json only.

A valid user that is part of IntegrationGroup.

<v1:ApplicationMessage xmlns:v1="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1">
<v1:family>XOrder</v1:family>
<v1:type>XOrderCre</v1:type>
<v1:businessObjectId>592824510</v1:businessObjectId>
<v1:payloadXml><&lt;XOrderDesc xmlns=&quot;http://www.oracle.com/retail/integration/base/bo/XOrderDesc/v1&quot; xmlns:ns0=&quot;http://www.oracle.com/retail/integra-tion/base/bo/CustFlexAttriVo/v1&quot;&gt;
&lt;order_no&gt;592824510&lt;/order_no&gt;
&lt;supplier&gt;99&lt;/supplier&gt;
&lt;currency_code&gt;USD&lt;/currency_code&gt;
&lt;terms&gt;13&lt;/terms&gt;
&lt;not_before_date&gt;2022-02-09T00:00:00Z&lt;/not_before_date&gt;
&lt;not_after_date&gt;2022-02-19T00:00:00Z&lt;/not_after_date&gt;
&lt;otb_eow_date&gt;2022-02-19T00:00:00Z&lt;/otb_eow_date&gt;
&lt;status&gt;A&lt;/status&gt;
&lt;exchange_rate&gt;1&lt;/exchange_rate&gt;
&lt;include_on_ord_ind&gt;Y&lt;/include_on_ord_ind&gt;
&lt;written_date&gt;2022-02-09T00:00:00Z&lt;/written_date&gt;
&lt;XOrderDtl&gt;
&lt;item&gt;174250093&lt;/item&gt;
&lt;location&gt;21&lt;/location&gt;
&lt;unit_cost&gt;10&lt;/unit_cost&gt;
&lt;origin_country_id&gt;US&lt;/origin_country_id&gt;
&lt;supp_pack_size&gt;1&lt;/supp_pack_size&gt;
&lt;qty_ordered&gt;2&lt;/qty_ordered&gt;
&lt;location_type&gt;W&lt;/location_type&gt;
&lt;reinstate_ind&gt;N&lt;/reinstate_ind&gt;
&lt;delivery_date&gt;2022-02-09T00:00:00Z&lt;/delivery_date&gt;
&lt;/XOrderDtl&gt;
&lt;orig_ind&gt;2&lt;/orig_ind&gt;
&lt;edi_po_ind&gt;N&lt;/edi_po_ind&gt;
&lt;pre_mark_ind&gt;N&lt;/pre_mark_ind&gt;
&lt;/XOrderDesc&gt;></v1:payloadXml>
</v1:ApplicationMessage>
HTTP/1.1 200 OK
Date: Thu, 10 May 2018 16:33:11 GMT
Content-Length: 33
Content-Type: application/json
X-ORACLE-DMS-ECID: 4a8e5d3f-1aae-43d7-ba84-c6b9c60563c7-00000039
X-ORACLE-DMS-RID: 0
Set-Cookie: JSES-SIONID=hsFK5jW4B1QtipC9zhng--or1WL7ywxCuxsJeVwdgPpnv6oNUnde!233126712; path=/; HttpOnly
{"message": "Inject successful."}

Success

If user in not added in IntegrationGroup

<v1:ApplicationMessage xmlns:v1="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1">
<v1:family>WH</v1:family>
<v1:type>WHCR</v1:type>
<!--Optional:-->
<v1:businessObjectId>?</v1:businessObjectId>
<!--Zero or more repetitions:-->
<v1:ApplicationMessageRoutingInfo>
<v1:name>?</v1:name>
<v1:value>?</v1:value>
<!--Zero or more repetitions:-->
<v1:ApplicationMessageRoutingInfoDetail>
<v1:name>?</v1:name>
<v1:value>?</v1:value>
</v1:ApplicationMessageRoutingInfoDetail>
</v1:ApplicationMessageRoutingInfo>
<v1:payloadXml>&lt;WHDesc xmlns=&quot;http://www.oracle.com/retail/integration/base/bo/WHDesc/v1&quot;&gt;&lt;wh&gt;10&lt;/wh&gt;&lt;wh_name&gt;g&lt;/wh_name&gt;&lt;/WHDesc&gt;</v1:payloadXml>
</v1:ApplicationMessage>
HTTP/1.1 403 Forbidden
Date: Thu, 05 Aug 2021 10:25:26 GMT
Content-Length: 1166
Content-Type: text/html; char-set=UTF-8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">
<HTML>
<HEAD>
<TITLE>Error 403--Forbidden</TITLE>
</HEAD>
<BODY bgcol-or="white">
<FONT FACE=Helvetica><BR CLEAR=all>
<TABLE bor-der=0 cellspac-ing=5><TR><TD><BR CLEAR=all>
<FONT FACE="Helvetica" COL-OR="black" SIZE="3"><H2>Error 403--Forbidden</H2>
</FONT></TD></TR>
</TABLE>
<TABLE bor-der=0 width=100% cellpad-ding=10><TR><TD VALIGN=top WIDTH=100% BGCOL-OR=white><FONT FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3>
</FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.4 403 Forbidden</H4>
</FONT>
<P><FONT FACE="Courier New">The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been ful-filled, it SHOULD de-scribe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is ap-plica-ble.</FONT></P>
</FONT></TD></TR>
</TABLE>
</BODY>
</HTML>

Failure

Wrong User/pass

<v1:ApplicationMessage xmlns:v1="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1">
<v1:family>WH</v1:family>
<v1:type>WHCR</v1:type>
<!--Optional:-->
<v1:businessObjectId>?</v1:businessObjectId>
<!--Zero or more repetitions:-->
<v1:ApplicationMessageRoutingInfo>
<v1:name>?</v1:name>
<v1:value>?</v1:value>
<!--Zero or more repetitions:-->
<v1:ApplicationMessageRoutingInfoDetail>
<v1:name>?</v1:name>
<v1:value>?</v1:value>
</v1:ApplicationMessageRoutingInfoDetail>
</v1:ApplicationMessageRoutingInfo>
<v1:payloadXml>&lt;WHDesc xmlns=&quot;http://www.oracle.com/retail/integration/base/bo/WHDesc/v1&quot;&gt;&lt;wh&gt;10&lt;/wh&gt;&lt;wh_name&gt;g&lt;/wh_name&gt;&lt;/WHDesc&gt;</v1:payloadXml>
</v1:ApplicationMessage>
HTTP/1.1 401 
WWW-Authenticate: Basic realm="Authentication required"
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 669
Date: Thu, 05 Aug 2021 05:08:40 GMT
Keep-Alive: timeout=20
Connection: keep-alive
<!doctype html><html lang="en"><head><title>HTTP Status 401 â€" Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 â€" Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat/8.5.64</h3></body></html>

Failure