Friday Feb 21, 2014

SOA Community Event

Im at the Fusion Middleware Community Event today in Malta, about 3pm I'll be presenting "Mobile Design Patterns for Apps Integration". 

I'll be posting the powerpoint here later, but if your around, say hello, if your not around Id be curious to hear your own design patterns. 

Monday Feb 10, 2014

Inserting a interaction into Sales Cloud using Java

Hey all,

Quick snippet of code showing how to create an interaction for an opportunity using Java.

This is only a snippet, I assume/note :

  • You've already created a Web-service proxy for the Interaction Service  (ie http://host/appCmmnCompInteractions/InteractionService) and added it to the project dependencie
  • You've tested a simple getInteraction() works fine
  • If you run standalone Java client, then make sure you import the Sales Cloud certificates into your keystore
  • If you run this as within Weblogic Server then the step of importing the Sales Cloud certificates isn't require
  • Tested and works on Sales Cloud R7
  • XML Payload is shown at the end
  • This is sample code



package oracle.fusion.pts.samples.clients;


import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;

import oracle.pts.fusion.samples.interaction.InteractionService;
import oracle.pts.fusion.samples.interaction.InteractionService_Service;
import oracle.pts.fusion.samples.interaction.ServiceException;

import weblogic.wsee.jws.jaxws.owsm.SecurityPolicyFeature;

public class createInteraction {

    //Define the security policy
    private static final SecurityPolicyFeature[] securityFeature =
        new SecurityPolicyFeature[] { new SecurityPolicyFeature("oracle/wss_username_token_over_ssl_client_policy") };

    private static final AddressingVersion WS_ADDR_VER = AddressingVersion.W3C;

    public static void main(String[] args) {
        // Default Values
        String username = "matt.hooper";
        String password = "somepassword";
        String url="https://yourhost:443/appCmmnCompInteractions/InteractionService";
        // Sample data, in a real system these would be either parameters to the function or queried as part of the code
        Long participantPartyId = new Long("100000000099058");
        String opportunityId="300000000667205";
        Long customerId= new Long("300000000592745");
        // Setup the webservice interface
        InteractionService_Service interactionService_Service = new InteractionService_Service();
        InteractionService interactionService = interactionService_Service.getInteractionServiceSoapHttpPort(securityFeature);
        // Get the request context to set the outgoing addressing properties
        WSBindingProvider wsbp = (WSBindingProvider)interactionService;
        Map<String, Object> requestContext = wsbp.getRequestContext();
        requestContext.put(WSBindingProvider.USERNAME_PROPERTY, username);
        requestContext.put(WSBindingProvider.PASSWORD_PROPERTY, password);
        requestContext.put(WSBindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

        System.out.println("Example of creating an interaction on a opportunity");
        // Create Payload        
        ObjectFactory factory = new ObjectFactory();
        Interaction newInteraction=factory.createInteraction();
        // Create XMLGregorianCalendar Object with todays date/time
        DatatypeFactory dtf=null;
        Date today= new Date();
        try {
            dtf = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            e.printStackTrace(); // Duh error
        GregorianCalendar gc=new GregorianCalendar();
        // Set Date
        newInteraction.setCustomerId(customerId);   // CustomerId can be obtained from TargetPartyId from the opportunity
        newInteraction.setInteractionDescription(factory.createInteractionInteractionDescription("Angelos Test Interaction "+today.toString()));        
        newInteraction.setOutcomeCode(factory.createInteractionOutcomeCode("SUCCESSFUL"));  // Configured in Setup/maintenance
        newInteraction.setInteractionTypeCode("EMAIL");         // Custom types can be configured
        newInteraction.setDirectionCode("INBOUND");             // INBOUND or OUTBOUND
        newInteraction.setMediaItemId(0L);                      // Default =0 
        newInteraction.setMediaTypeCode(factory.createInteractionMediaTypeCode(""));// Leave Empty
        // Create & Add Participant, can be RESOURCE and/or CONTACT        
        InteractionParticipant participant= factory.createInteractionParticipant();
        // Create  & Add Association, this links it back to Opportunity
        InteractionAssociation association = factory.createInteractionAssociation();
        // Do the insert
        Interaction result=null;
        try {
            result = interactionService.createInteraction(newInteraction);
        } catch (ServiceException e) {
        System.out.println("end - interaction "+result.getInteractionId()+" created");



 <soapenv:Envelope xmlns:soapenv="" xmlns:typ="" xmlns:int="">
            <int:InteractionEndDate xsi:nil="true" xmlns:xsi=""/>
<!-- CustomerID= SalesParty Customer, also known as TargetPartyId in Opportunity -->
            <int:InteractionDescription>CTI Detected customer callback </int:InteractionDescription>
<!-- InteractionTypeCode is part of the standard Lookup types -->
            <int:MediaTypeCode xsi:nil="true" xmlns:xsi=""/>
<!-- ParticipantId is partyID for contact -->
<!-- AssociatedObjectUid is OPPORTUNITY you want to assocaite this with -->


Monday Jan 13, 2014

More complete RESTful Services for Oracle Sales Cloud Sample/Demo Application

This sample code builds on the previous code examples in my blog showing how you can create a RESTful Facade for Oracle Sales Cloud. Specifically this example concentrates on the six main objects people tend to work with :

  • Opportunities
  • Leads
  • Locations
  • SalesParty
  • Person
  • Interactions

This application is an extension of a previous blog article, it is recommended that this article, and tutorial, are followed first. 

Please note this code is SAMPLEWARE and delivered with no guarantees, warranties or  support

Functionality / Features

  • Supports Oracle Sales Cloud Release 7 and JDeveloper
  • Ability to query data in a RESTFul way (using GET/PUT verbs)
  • Data can be queried using JSON or XML data formats
  • URIs can contain parameters which reduce the amount of data which is returned , e.g. only bring back Opportunity IDs and Names
  • URI can contain SIMPLE queries, e.g. where OptyID=12323232
  • Complex queries can be passed in as a POST query when the URI ends in /xmlquery
  • User Credentials, CRM Server, FetchSize and FetchStart can be provided in httpHeaders, thus can be encrypted by SSL
  • Default Server can be setup so that credentials are not needed
  • Project can be extended to cover other objects


  • Read only is implemented, if you want to issue writes (PUTS) or updates then I recommend custom methods for each operation you require.
  • In the future Oracle Sales Cloud will likely have support REST support natively; This software will work fine against future versions of Oracle Sales Cloud but you are probably better off using the native Oracle Sales Cloud REST support when it 


Monday Jan 06, 2014

New Book on Fusion Apps Development & Extensibility

If your doing anything with Oracle Fusion Apps, you really ought to read this newly released book. Its a great start, but just beware that some of the content isn't applicable to the "Cloud" variants of Fusion Apps, BUT it really helps to know how it works under the covers.. 

Its available on OReily Safari,  or you can also purchase the book on sites like Amazon

Using EL Expressions in Fusion Applications

Hey all,

Happy New Year!

If your using FusionApps, and are wondering what can you modify on the screen, its worth checking out this video. It demonstrates the usage of EL to hide/show fields based on values on the screen.

Thursday Oct 24, 2013

JAXB Errors and Best Practices when Generating WebService Proxies for Oracle Sales Cloud (Fusion CRM)

I've recently been building a REST Service wrapper for Oracle Sales Cloud and initially all was going well, however as soon as I added all of my Web Service proxies I started to get weird errors.. 

My project structure looks like this

What I found out was if I only had the InteractionsService & OpportunityService WebService Proxies then all worked ok, but as soon as I added the LocationsService Proxy, I would start to see strange JAXB errors.

Example of the error message

Exception in thread "main" Unable to create JAXBContext
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.buildRuntimeModel(
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.internalGetPort(
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate$PortClientInstanceFactory.createClientInstance(

Looking further down I see the error message is related to JAXB not being able to find an objectFactory for one of its types

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 6 counts of IllegalAnnotationExceptions
There's no ObjectFactory with an @XmlElementDecl for the element {}AssigneeRsrcOrgId
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement at

This is very strange... My first thoughts are that when I generated the WebService Proxy I entered the package name as "oracle.demo.pts.fusionproxy.servicename" and left the generated types as blank. This way all the generated types get put into the same package hierarchy and when deployed they get merged...

Sounds resaonable and appears to work but not in this case.. 

To resolve this I regenerate the proxy but this time setting :

Package name : To the name of my package eg. oracle.demo.pts.fusionproxy.interactions
Root Package for Generated Types :  Package where the types will be generated to, e.g. oracle.demo.pts.fusionproxy.SalesParty.types

When I ran the application now, it all works , awesome eh????

Alas no, there is a serious side effect.

The problem now is that to help coding I've created a collection of helper classes , these helper classes take parameters which use some of the "generic" datatypes, like FindCriteria.

e.g. This wont work any more

public static FindCriteria createCustomFindCriteria(FindCriteria pFc,String pAttributes)

Here lies a gremlin of a problem.. I cant use this method anymore, this is because the FindCriteria datatype is now being defined two, or more times, in the generated code for my project. If you leave the Root Package for types blank it will get generated to, and if you populate it then it gets generated to your custom package.. The two datatypes look the same, sound the same (and if this were a duck would sound the same), but THEY ARE NOT THE SAME...

Speaking to development, they recommend you should not be entering anything in the Root Packages section, so the mystery thickens why does it work..

Well after spending sometime with some colleagues of mine in development we've identified the issue.. Alas different parts of Oracle Fusion Development have multiple schemas with the same namespace, when the WebService generator generates its classes its not seeing the other schemas properly and not generating the Object Factories correctly... 

Thankfully I've found a workaround

Solution Overview

  • When generating the proxies leave the Root Package for Generated Types BLANK
  • When you have finished generating your proxies, use the JAXB tool XJC and generate Java classes for all datatypes 
  • Create a project within your JDeveloper11g workspace and import the java classes into this project
  • Final bit.. within the project dependencies ensure that the JAXB/XJC generated classes are "FIRST" in the classpath

Solution Details

  • Generate the WebServices SOAP proxies
    • When generating the proxies your generation dialog should look like this

    • Ensure the "unwrap" parameters is selected, if it isn't then that's ok, it simply means when issuing a "get" you need to extract out the Element
  • Generate the JAXB Classes using XJC
    • XJC provides a command line switch called -wsdl, this (although is experimental/beta) , accepts a HTTP WSDL and will generate the relevant classes. You can put these into a single batch/shell script
    • xjc -wsdl https://fusionservername:443/appCmmnCompInteractions/InteractionService?wsdl
      xjc -wsdl https://fusionservername443/opptyMgmtOpportunities/OpportunityService?wsdl

  • Create Project in JDeveloper to store the XJC "generated" JAXB classes
    • Within the project folder create a filesystem folder called "src" and copy the generated files into this folder. JDeveloper11g should then see the classes and display them, if it doesnt try clicking the "refresh" button

  • In your main project ensure that the JDeveloper XJC project is selected as a dependancy and IMPORTANT make sure it is at the top of the list. This ensures that the classes are at the front of the classpath

And voilà..

  • Hopefully you wont see any JAXB generation errors and you can use common datatypes interchangeably in your project, (e.g. FindCriteria etc)

Friday Sep 27, 2013

REST Enabling Oracle Fusion Sales Cloud using Java

Oracle Fusion Sales Could (Rel7) currently has a WebServices/SOAP interface however many clients & partners are interested in accessing Oracle Fusion Sales Cloud using REST & JSON. The main difference between a SOAP service and a REST service is the “way” you get access to the data and methods you use. Whilst SOAP is very powerful, very complete and also can be quite complex perhaps over-complex. REST in comparison is rather simple and uses the http verbs (GET,POST,PUT etc) to define the operation and can be as powerful as you desire.

There are many documents on the web which discuss REST vs SOAP but in summary :              


Originally defined as Simple Object Access Protocol.

A protocol specification for exchanging structured information in the implementation of Web Services in computer networks.

An envelope, which defines what is in the message and how to process it
A set of encoding rules for expressing instances of application-defined datatypes
And a convention for representing procedure calls and responses.

Relies on eXtensible Markup Language (XML) as its message format, and usually relies on other Application Layer protocols (most notably Remote Procedure Call (RPC) and HTTP) for message negotiation and transmission.

This XML based protocol consists of three parts:


RESTful web service (also called a RESTful web API) is a simple web service implemented using HTTP and the principles of REST. Such a web service can be thought about as a collection of resources. The definition of such a web service can be thought of as comprising three aspects:

The base URI for the web service, such as

The MIME type of the data supported by the web service. This is often JSON, XML or YAML but can be any other valid MIME type.

The set of operations supported by the web service using HTTP methods (e.g., POST, GET, PUT or DELETE).




Why would you want to use REST instead of SOAP?

There are many reasons why one would/could want to use REST instead of SOAP, one reasons is that SOAP is considered too heavy-weight for mobile applications, where payload size is critical, and also instead of XML, JSON is the preferred  message format.

The JSON message format is also very appropriate when interfacing with systems that use JavaScript (such as browsers or node.js) and hence adds weight to the desire to use REST instead of SOAP for accessing Oracle Fusion Sales Cloud.

So getting to the matter at hand and getting RESTful

So enough of why REST , how does one do it for Oracle Sales Cloud (aka CRM). Thankfully this is rather straightforward, at Oracle OpenWorld 2013 you would have seen Thomas Kurian demonstrate our new Oracle SOA Suite and how it can transform a SOAP service into a REST service whilst this is excellent and incredibly productive some clients dont want to install SOA Suite soley for this purpose. Thankfully its possible to do the same using pure Java and deploy it to a cloud infrastructure, like the newly release Oracle Java Cloud Service. It is however worth noting that using SOA Suite is preferable because it accelerates the deployment tremendously and would ultimately be more "agile". 

So what are the basic steps to REST enable a Fusion Sales Cloud Service?  

  1. Download and install the Jersey REST libraries, we'll use these for the creation of the RESTful service
  2. Generate the SOAP Client Side Proxie(s) for Oracle Sales Cloud. In this example we're using static proxies however for a more industrialized approach Id recommend going down the dynamic proxy route, more flexible and less likely to break at runtime, however at a development cost.
  3. Create "wrapper" JAXB Objects so that you can return XML data. This is needed because the baseline SOAP clients dont have @RootElement  (s) defined.
  4. Create the RESTful project and expose the services you require.
  5. Deploy to your runtime Java contain, like the Oracle Java Cloud Service
  6. Consume by your favourite client, like a mobile phone etc 

For the purpose of the tutorial (in the document), I've documented step by step how you can build the above, query Oracle Fusion Sales Cloud, manage security  (for development & production) and how to deploy the code to the Oracle Java Cloud. Obviously take note that this document is more of a tutorial than anything else when building your own custom REST Adaptor you would tailor it specifically to what services your client (mobile phone, javascript widget etc) requires.

Happy reading



This document and source code is sample code and assumes no support from Oracle Corporation or myself. 

Wednesday Sep 25, 2013

Sample Payload : Batch insert/update

Question came up in a call today, is it possible to do batch webservice updates using the Oracle Sales Cloud webservice interface??

The answer is YES, but not all webservices support this. The operation is called "process<ObjectName>",and you need to check in the ADFService list of operations, in FusionOER , that the service supports the process<xxx> syntax.

For example LocationService and  OpportunityService support the process operation but the SalesPartyService does not.

Also you will find there are typically two operations, process<object> and processCS<object> the difference being that the first one you supply it with a list of objects and one operation (ie update all locations), whereas in processCS you can provide a unique operation for each and every object.

From FusionOER for the opportunity service

Operation Description  Parameters  Return value
processOpportunity Performs a Create, Update, Delete, or Merge operation on a list of Opportunity rows. The specified operation is applied to all objects in the given list. String changeOperation ,
java.util.List Opportunities,
processControl oracle.jbo.common.service.types.ProcessControl

 A list of opportunities that are successfully processed
processCSOpportunity  Performs a Create, Update, or Delete operation on a list of Opportunity rows. Different operations may be applied to different objects, depending on what is specified in the ChangeSummary object.

oracle.jbo.common.service.types.ProcesssData processData,
processControl oracle.jbo.common.service.types.ProcessControl

 A list of opportunities that are successfully processed

And a sample payload looks like

<soapenv:Envelope xmlns:soapenv="" xmlns:typ="" xmlns:loc="" xmlns:par="" xmlns:sour="" xmlns:loc1="" xmlns:typ1="">
            <loc:Address1>510 Quercia Marcozzi</loc:Address1>
            <loc:Address2>Building 300</loc:Address2>
            <loc:Address1>510 Quazi Marcozzi 2</loc:Address1>
            <loc:Address2>Building 500</loc:Address2>

Monday Aug 12, 2013

Some Fusion CRM payloads for creating SalesAccounts

Some payloads for creating customers in FusionCRM, namely

  • Create a location in Fusion CRM
  • Add the location to the Sales_Prospect making it into a SalesAccount
  • Add a sales person to the SalesAccount
  • Make the salesPerson the primary account owner

1.       Create a new  Location, using createLocation in the  LocationService

<soapenv:Envelope xmlns:soapenv="" xmlns:typ="" xmlns:loc="" xmlns:par="" xmlns:sour="" xmlns:loc1="">






            <loc:Address1>510 Quercia Marcozzi</loc:Address1>

            <loc:Address2>Building 300</loc:Address2>









2. Add the location to the Sales_Prospect making it into a SalesAccount using SalesPartyService

<soapenv:Envelope xmlns:soapenv=""















       <soapenv:Header />




                           <!-- PartyID of the organization -->



                                  <!-- PartyID of the organization -->



                                         <!-- PartyID of the organization -->


                                         <!-- PartyID of the location you wish to add -->


                                         <!-- Module which created the entry, ZCM is the code for the UI, can

                                                be others -->












3.       Add the Resource(SalesPerson) to the SalesAccount, using createSalesAccountResource, in the SalesPartyService

<soapenv:Envelope xmlns:soapenv="" xmlns:typ="" xmlns:sal="">





<!—The code indicating how the resource is assigned to the sales account team. The possible values are contained in the ZCA_ASSIGNMENT_TYPE lookup.à


            <sal:ResourceId>300000000623680</sal:ResourceId>             <sal:SalesAccountId>300000000690006</sal:SalesAccountId> </typ:salesAccountResource>


4.       Make the new person the Account Lead, using updateSalesParty, in SalesPartyService

<soapenv:Envelope xmlns:soapenv="" xmlns:typ="" xmlns:sal="" xmlns:org="" xmlns:par="" xmlns:con="" xmlns:sour="" xmlns:con1="" xmlns:org1="" xmlns:par1="" xmlns:rel="" xmlns:org2="" xmlns:rel1="" xmlns:per="" xmlns:per1="">

5.    <soapenv:Header/>

6.    <soapenv:Body>

7.       <typ:updateSalesParty>

8.          <typ:salesParty>

9.             <sal:PartyId>100000000055273</sal:PartyId>

10.             <sal:SalesAccountId>300000000629280</sal:SalesAccountId>

11.          </typ:salesParty>

12.       </typ:updateSalesParty>

13.    </soapenv:Body>

14.               </soapenv:Envelope>

Tuesday Jun 11, 2013

Exporting Items

Following on from the previous article, an easy way of exporting the InventoryItemIds is to use the Embedded BI Publisher in Fusion Applications

Login as a Fusion Systems Administrator, and select Reports and Analytics

Create a Report 

Create a new data model

Give the Data Model a name and store it in a folder 

 Now select the data set and create a "SQL Query" 

Enter the SQL query. For items there are two tables we need to be concerned with egp_system_items_b  (the base table) and egp_system_items_tl (contains the translated descriptions). We need to query both tables even if we dont have any translations as the base language description is stored in the translations table.

Select the datasource to be "ApplicationDB CRM", although this might change for your installation/version

 After saving this dialog and hitting the screens save button on the far right hand side

 Then select the XML icon, this allows us to run the query AND export the data as XML

The result!

and yes you can export it to a file 

Monday Jun 10, 2013

FusionCRM :Adding a Product Item and a Product Group to a CRM Opportunity

Recently it was asked to me how one can insert a product item/group into a Fusion CRM Opportunity. First thing is one needs to understand the difference between a CRM Product Item and a CRM Product Group. 

A Product Item is a Item, usually managed externally from Fusion CRM, often from Fusion PIM or uploaded independantly.

A  Product Group is a collection of Product Items collected together in the "Manage Product Group" screen within Fusion Setup and Maintenance.

When inserting into an opportunity a product group, or a product item, you will need to know the product group ID (ProdGroupId) or the InventoryItemIds+InventoryOrgId respectively.

You can get a list of all your product group IDs, by exporting the object "ProductGroupDetailExpPVO" in the "Schedule Export Processes" task within "Setup and Maintenance" 

The payload for inserting a product Item within an Opportunity is

and for inserting a ProductGroup is similar but for product groups you dont need the InventoryOrgId.

Finally if you want to do this as part of a groovy script,e.g trigger from a button, the script would look something like this

Thursday Jun 06, 2013

ADF Mobile Local Database and Offline support

Hey all,

Frederic from our product mgmt team has produced a nice short (32min) webcast on the Local database (SQLite) in ADF Mobile and  specifically he discusses how to use it to implement offline support in your ADF Mobile applications.

 Nice webinar...

Check it out here

Friday Apr 05, 2013

Debugging ADF Mobile apps, quick tip

Don't you miss the Weblogic console when developing Oracle ADF Mobile applications?? I do..  Well there is a neat workaround for Android.

Oracle ADF Mobile outputs quite a bit of debug information onto the Android logcat, which is quite useful.

To see the Android logcat, you can execute the following command (Windows or Linux)

adb logcat

and logcat will continue logging everthing which happens on your android phone to your operating systems command line..

However a better approach is to use Eclipse logcat.

 If you install eclipse and install the Android Development Toolkit  (link) you get the same functionality as the command line logcat, but with the additional features

I've since discovered that the Android SDK actually has a program called "Monitor" which appears to be an Eclipse based UI dedicated for debugging your device.. It has information on the heap, threads,network statistics and lots more! but importantly for us the logcat functionality is identical to whats available in eclipse (same plugin I guess)

  • Pretty colours, makes it easier to see Information vs Debug messages
  • A quick & easy UI for setting up filters , so you can configure it to filter only for messages from your application  


Tuesday Oct 30, 2012

Oracle Launches Mobile User Experiences Design Patterns

Mobile design requires a different way of thinking. Use Oracle’s mobile design patterns to design iPhone, Android, or browser-based smartphone applications.  We are sharing our mobile design patterns and their baked-in, scientifically proven usability to enable Oracle customers and partners to build mobile apps quickly.

Our design patterns are common solutions that developers can easily apply across all application suite products. Crafted by our insight into Oracle Fusion Middleware, the patterns are designed to work with the mobile technology provided by the Oracle Application Development Framework

Tuesday Sep 25, 2012

Oracle ADF Essentials - An free version of Oracle ADF

Not sure if you’ve seen this announcement, but Oracle have launched a free version of Oracle ADF, named ADF Essentials..

Its basically a  version of Oracle ADF which can also run on other app Servers and contains the full ADF Stack from ADF Faces , ADF Controller/Model and ADF Business Components.

See here for more information

also see an independent review at


Architect & Technology Evangelist - If its middleware,PaaS/SaaS integration then I'm interested

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.


« November 2015