This chapter provides an overview of the following two API's:
Instance Message Java API for programmatically accessing instance message data.
Partner Metadata API for retrieving partners metadata information like Identifiers list, parameters, contact information details.
This chapter contains the following topics:
For more information about the Instance Message API, InstanceMessageUtil
class, see Oracle Fusion Middleware B2B Instance Message Java API Reference.
Instance Message Java API is a Java API provided in Oracle B2B to retrieve runtime data that is exchanged between Trading Partners.
Some Instance Message Java API use cases include:
Resubmitting from a back-end application
Checking the status for a particular order number
Payload introspection by a back-end application
Checking the remaining retries for the message
Checking the wire message of the payload
Instance Message API queries the runtime data and provides results in the form of Instance data for various criteria. Instance Message API is a java wrapper on top of Instance Message View which encapsulates both business and wire messages.
Note:
When using this API, you must set additional libraries as part of the classpath in addition tob2b.jar
and weblogic.jar
or wlthint3client.jar
.Instance Message API Query Options
The Instance Message Java API enables you to retrieve the instance messages based on the following criteria:
Agreement name
Control number, group control number, transaction control number, Trading Partner name, and document type
Date range and Trading Partner
Date range, direction, and Trading Partner
Message ID
Message state
Protocol message ID
Trading Partner
Trading Partner and direction
Trading Partner and document type
Trading Partner and message state
Xpath expression (can be evaluated on one or two XPath expressions)
XPath value (can be evaluated on one or two XPath expressions)
Conversation ID
For more information about the Instance Message API, see Oracle Fusion Middleware B2B Instance Message Java API Reference.
You can write your logic based on the out put of
Vector messages = (Vector) imUtil.getInstanceMessagesForTP("GlobalChips")
as shown in Example 26-1.
Another similar exposed method is getInstanceMessagesForMsgId(String messageId)
. All of the methods are documented in Oracle Fusion Middleware B2B Instance Message Java API Reference.
Example 26-1 Retrieval based on Trading Partner Name
import java.util.Vector; import oracle.tip.b2b.utility.InstanceMessageUtil; public class MyInstanceData { public static void main(String[] args) throws Exception { InstanceMessageUtil imUtil = new InstanceMessageUtil(); Vector messages = (Vector) imUtil.getInstanceMessagesForTP("GlobalChips"); System.out.println(messages.size()); } }
See the following topics for troubleshooting information:
If the query returns a large number of messages then the weblogic.socket.MaxMessageSizeExceededException
may occur.
To recover from this issue, increase weblogic.MaxMessageSize
, and pass -Dweblogic.MaxMessageSize=100000000
in the client command line. This parameter setting will allow you to receive 100 MB messages.
For example:
java -cp .:$ORACLE_HOME/wlserver_10.3/server/lib/wlthint3client.jar:$SOA_HOME/ /soa/modules/oracle.soa.b2b_11.1.1/b2b.jar -Dweblogic.MaxMessageSize=100000000 TestInstanceMsg
Rather than return the payload itself, a large inbound or outbound payload will return as a reference to the location of the payload.
For example:
/tmp/GlobalChips_1_custnonxml_largepayload.dat@9844C4341297D3EB7B60000011A0CC9D .dat
See Appendix A, "Handling Large Payloads" for more information about how Oracle B2B handles large payloads.
If while using weblogic.jar
and executing queries remotely you may see classpath issues for Oracle WebLogic Server, and the java.lang.ClassNotFoundException:weblogic.security.subject.AbstractSubject
exception.
To recover, execute queries using wlthint3client.jar
.
For example:
java -cp .:$ORACLE_HOME/wlserver_10.3/server/lib/wlthint3client.jar:$SOA_HOME/ /soa/modules/oracle.soa.b2b_11.1.1/b2b.jar TestInstanceMsg
In order to retrieve partners metadata information like Identifiers list, parameters, contact information details, the partner metadata API class oracle.tip.b2b.utility.MetadataUtil.java has been introduced. This API contains the following methods to help client retrieve metadata information:
public String getTradingPartnerName(String identifierType, String identifierValue) throws Exception
This method retrieves Partner Name by taking Identifier Type and Identifier Value as arguments. If provided Identifier Type or Identifier Value or both are nonexistent, returned Trading Partner name is null.
Note:
Any two Trading Partners must not be configured with same Identifier Type and Identifier Value pair. This method returns a single Trading Partner name for a pair of Identifier Type and Identifier Value.public Map<String, List<String>> getIdentifiers(String tpName) throws Exception
This method returns a Key-Value pair (Map) of Parameter Name and its Value for a given Trading Partner (TP). Individual values can be extracted by iterating through this map.
If the given TP name is nonexistent, you receive an exception with the message as -”Trading Partner does not exist”.
public Map<String, String> getTradingPartnerParameters(String tpName) throws Exception
This method returns a Key-Value pair (Map) of Parameter Name and its Value for a given Trading Partner. Individual values can be extracted by iterating through this map. If provided TP name is nonexistent, you receive an exception with message as -”Trading Partner does not exist”.
public Map<String, List<String>> getContactInfo(String tpName) throws Exception
This method returns a Key-Value pair (Map) of Contact Information Type and its Value/s for a given Trading Partner. If a Contact Information Type has multiple values, retrieved map will contain whole list of values. Individual values can be extracted by iterating through this map.
If provided TP name is nonexistent, you receive an exception with message as -”Trading Partner does not exist”
The following sample code shows the usage of the API. This can be run by passing Identifier Type, Identifier Value and TP Name arguments.
Example 26-2 Sample Code - Partner Metadata API
import java.util.Map; import oracle.tip.b2b.utility.MetadataUtil; public class MyDesignTimeData { public static void main(String[] args) throws Exception { MetadataUtil mdUtil = = new MetadataUtil(); String tpName = "GlobalChips"; Map<String, List<String>> identifiersMap = mdUtil.getIdentifiers(tpName); } }
In order to rub this sample code, b2b.jar, weblogic.jar and jndi.properties file need to be in the classpath. The jndi.properties file must have following entries:
java.naming.provider.url=t3://<localhost>:<port>
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.security.principal=<username>
java.naming.security.credentials=<password>