Monday May 04, 2015

Getting started with Sales Cloud (Updated)

Hey all, Ive just reviesed the Getting Started with Oracle Sales Cloud Integrations blog entry with a few more links

Friday Dec 05, 2014

Getting JDeveloper HttpAnalyzer to easily work against SalesCloud

Hey all

Little tip here. If your trying to debug some Java code working against SalesCloud one of the tools you might try and use is the http analyzer.. Alas I couldn’t get it to recognize the oracle sales cloud security certificate and the currently version of JDeveloper (11.1.1.7.1) doesnt give you an option to ignore the certificate..

However.. there is a workaround, simply start JDeveloper using a special flag which tells JDevelopers Http Analyzer to trust everybody!

jdev -J-Djavax.net.ssl.trusteverybody=true

Very useful…and obviously for testing and development its ok, but not for anyting else

For more information please see this  Doc reference

Thursday Dec 04, 2014

Getting Started with Oracle Fusion Cloud Integrations

Updated: 4-May-2015

Hey all,

If your getting started with integrating your application with Oracle Fusion Cloud then I wholeheartedly recommend you read the following resources before starting.. Most of the below is specific to Oracle Sales Cloud because it has App Composer, however much of the below is also applicable to HCM, ERP and other Fusion products.. 

Some of these are a MUST have read before you start integrating/coding/customizing :-) I've put them here in the order I think would work for most people... Kinda like a getting started check-list

I consider this blog entry an living blog entry, in that  I'll be updating it on a regular basis, so make sure you periodically check this location 


Top 5 Fusion Integrations Must Reads 

1. Familiarise yourself with the Sales Cloud Documentation. Specifically :

    • Go through the "User" section, documents like "Using Sales Cloud", "book. If your a techie like me you'll sit there and think, "Hey this is functional why do I need to read this?", well you do.. Even as a technical person, reading through the various user documents like the Using Sales Cloud" bits as an end user helps you understand what the different concepts/topics are.. You'll also understand things like the difference between a Prospect and a Sales Account, territories, assessments and much more.. Its worth a quick read, but do make sure you have a functional consultant to hand to make sure your not building something which can be done by configuration....
    • Read through all the books in the "Extensibility" section. The only anomaly here is the "Business Card Scanner mobile App" document. Its a walk-through of how to integrate Sales Cloud with a 3rd party Service to do business card scanning with MAF... Id leave that till last...
    • Peruse the Development section, this section contains a number of example use-cases, ie how to create a customer in R8, how to call an outbound service, its a good read....
2. Get an overview of the tasks you might do...
    • Once you've this then look at the "Tasks" section of the docs....Here the curriculum development folk have categorised some of the most common tasks and put short cuts to the documentation detailing how to do this.. e.g. like adding a field to Sales Cloud, calling a soap webservice etc
3. Are you going to be customizing the SalesCloud User Interface?
    • Many Sales Cloud integrations involve customizing the Sales Cloud User Interface. The customization could be as simple as adding a few fields to a standard object (like Opportunity), creating new objects (like MyOrder), validation or adding external content to one or many pages.
    • If your adding fields make sure you read the "Introduction to SalesCloud Customizations" section.
    • If you will be adding validation, triggers or calling webservices from Sales Cloud then make sure you read up on groovy scripting, and specifically the chapter on calling outbound SOAP webservices from groovy.
    • Make sure you understand the difference between calling a SOAP Service from groovy and creating an outbound webservice call using object workflows
      • In a nutshell , calling SOAP Services from groovy is a synchronous call, and calling a SOAP Service from a object workflow is a fire-and-forget asynchronous call
      • If you need to make sure an outbound webservice call is executed successfully then call the outbound webservice from a groovy script and surround it with an exception handler to catch any errors
    • On the subject of groovy be aware that in Sales Cloud you do not have access to the entire groovy language, thus make sure you understand that we only support a number of groovy functions (white-listing) and these are documented at the end of the book , Appendix A Supported Groovy Classes and Methods
4. Are you going to be accessing data from SalesCloud from the external app??
    • If you think you will be calling SOAP WebServices in Sales Cloud then the "Getting started with WebServices" is a MUST read...  This doc goes into details into how to look up the SOAP webservice in Fusion OER, how to create static proxies, querying data and how to perform CRUD operations...
    • Get to know Oracle Fusion OER,, its a gold mine of information.......
    • Read Arvinds ( A-Team Chronicles Blog ) excellent "Invoking Sales Cloud SOAP Services from external Applications (part 1)" blog entry. This blog entry describes the steps aronud looking up a SOAP service (ie Opportunities) and then how to create a SOAP JAX-WS static proxy using JDeveloper11g. I personally would the JAX-WS Proxy approach (vs the Data Control) and then building Java code around this to support your application.
5. Do you need your app to know who is calling it? 
    • Many integrations involve embedding a 3rd party web app into Oracle Sales Cloud as an iFrame or pressing a button in SalesCloud and calling the 3rd party app (either a UI or WebService call) . If your doing this then you'll almost certainly need to pass a "token" to the 3rd party application so it can use that it can call back to Sales Cloud with a key rather than a plain text username/password combo.. We call this key JWT TOKEN and its based on industry standards (http://jwt.io/) .  For a starters read my JWT Getting started blog  entry and then use the links to read the core documentation

That covers the top 5 areas of integration.. Now for a list of locations where you can get even MORE useful information :

More Information

  1. Oracle Learning Centres Quick Webinars on SalesCloud Integration
    • I worked with Development to get this mini tutorial series done, its excellent but Im obviously not biased eh  ;-) 
  2. R9 Simplified WebServices doc
    • This is a new document we recently completed based on how to use the new R9 Simplified SOAP TCA Services..  Although the document is targetted at R9 developers, it covers many of the standard topics like how to create a proxy, how to create a create operation etc.. It even has some sample CRUD payloads which are really really useful 
  3. Oracle Fusion Developer Relations
    1. Good friends of mine, they host a fantastic blog, youtube channel and whitepapers for Fusion Developers, another gold mine of information covering customization , extensions and integration code.
  4. Oracle Fusion Developer Relations
    1. Youtube channel : Not content with an awesome blog the Developer Relations folk even have a you tube channel where they host a collection of short "tutorials", showing all sorts such as "How to add a field to a page" , " How to call a webservice" etc..
    2. Oracle Fusion Developer Relations Whitepapers
  5. And finally there is my humble blog (which you are reading now) where I try and blog on things which aren't documented anywhere else.. If they are documented and are interesting I often link to it.. mainly because I want to find it myself :-)

Thats it folks!

If there are blog entries you'd like to see, or specific how to's, then feel free to contact me at angelo.santagata@oracle.com

Angelo 


Monday Oct 13, 2014

Extending SaaS with PaaS free eLearning lectures

Hey all,

Over the last 4 months I've been working with some of my US friends to create a eLearning version of the PTS SaaS extending PaaS workshop I co-wrote....., Well the time has come and we've published the first 4 eLearning seminars, and I'm sure there will be more coming.

Check em out and let me know what you think and what other topics need to be covered.

https://apex.oracle.com/pls/apex/f?p=44785:24:0::::P24_CONTENT_ID,P24_PREV_PAGE:10390,24

Thursday Oct 09, 2014

Generating Sales Cloud Proxies using Axis? Getting errors?

If your generating SOAP proxies using Apache Axis/2 you may find yourself hitting strange errors.. Whats even stranger is that you can generate proxies using JDeveloper and it works fine in tooling like SOAPUI.. Well help is at hand..

The most common error is

IWAB0399E Error in generating Java from WSDL:  java.lang.RuntimeException: Unknown element _value

I'm not sure if this is a bug in Fusion Sales Clouds base tech (ADFBC SDOs) or a bug in Apache Axis but there is a workaround and engineering are looking into this.

For a workaround you have two options

  1. Use adb binding and set the flag –Eosv to turn off strict validation.
  2. Use JDK xjc command to generate the JAXB classes:
  3. e.g. xjs -wsdl http://<salescloudsoapendpoint/opptyMgmtOpportunities/OpportunityService?WSDL

Enjoy and let me know if this works for you :-) 

 

Angelo 

Thursday Sep 18, 2014

Oracle Applications Cloud Release 8 User Experience Rapid Development Kit

Good resources from the UX Team

If you’re building or integrating the Oracle Applications Cloud or building SaaS through PaaS, use the User Experience Rapid Development Kit laid out here to get the guidance you need and point you to the right tools to use.

The Oracle Applications User Experience team has released a User Experience Rapid Development Kit on simplified user interface (UI), the same user experience design in Oracle Applications Cloud release 8. The kit is designed to help Oracle ADF developers get up to speed quickly so they can start designing and building the Oracle Applications Cloud simplified UIs, which are the tablet-friendly UIs for Oracle Sales Cloud and Oracle HCM Cloud, in a matter of hours.

The User Experience Rapid Development Kit contains the following tools:

  • Coded ADF page templates.
  • Coding tips from Oracle’s developers.
  • ADF screen overlays showing the use of components in the simplified UI.
  • An eBook on user experience (UX) design patterns and guidelines(right), and example wireframe stencils of page types and components in Microsoft Visio and Balsamiq Mockups formats.
  • Sample wireframe of a simplified UI page flow.

How would you like to get started?

Tell me more about the simplified user interface for Oracle Applications Cloud.

Show me demos of simplified UI in the Oracle Applications Cloud.

What’s coming next in the Oracle Applications Cloud user experience?

Start Designing and Building a Simplified User Interface

Learn more

Wednesday Jul 30, 2014

Fusion Developer Relations Resources - A must have for Sales Cloud integrators

All,

Full Disclosure I received this from an email from Apps Developer Relations but its soooo good I wanted to share it with all. Bottom line if your integrating your product/package/system with Sales Cloud after you've perused the standard documentation (which we are evolving rapidly) this is a treasure trove of articles/blogs/viewlets you can use.. 

Obviously use this in conjunction with the standard Oracle Cloud Documentation (http://docs.oracle.com/cloud/latest/salescs_gs/index.html

Enjoy!

Title:

Introducing the Oracle Fusion Applications Developer Relations Team

Abstract:

You’ll find a wealth of resources and hands-on expertise available from the Oracle Fusion Applications Developer Relations Team.

:

If you are evaluating or designing customizations and extensions for your Fusion Applications environment (SaaS or On-Premises) then you’ll find a wealth of resources and hands-on expertise available from this Oracle group. The team was formed to help customers and partners be successful with their development projects using the Fusion Applications platform, and provide the following publically available services:

  • An extensive Blog Site with over 150 articles covering many types of customization, extension, and integration.
  • An open Forum Site for technical questions from the development community.
  • A popular YouTube Channel with over 100 bite-size videos demonstrating a broad range of customization and extension features.
  • Whitepapers on topics including custom application development, ESS development, and Groovy and Expression Language.

So check out their resources or get in touch, and make your own development project tasks a little easier.

Friday Jun 13, 2014

Using SalesCloud RESTFacade with Custom Fields & CORS support

Some of you may be using my RESTFacade which I wrote and Oracle recently released as sample code on OTN (link).

There has been a couple of requests, or more "how to"s which I thought Id post here.

  1. How to add CORS support (Cross Origin Resource Sharing) support
  2. How to use the facade with custom fields defined in AppComposer

How to add CORS support (Cross Origin Resource Sharing) support

 Adding CORs support is quite straightforward, simply open the web.xml file in the FusionRESTService project and add the following <init-param>

<init-param>
 <paramname>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>oracle.fusion.pts.ResponseCorsFilter</param-value>
</init-param>

Simples :-)

How to use the facade with CustomFields

This one is a little trickier. The facade uses a collection of static proxies and although I am planning to rewrite the proxies as "dynamic" proxies we're not there yet (and I need to do some reading first).

The only way to use custom fields with the facade today is to regenerate the proxies against your Sales Cloud instance. Here I will go through the steps you will need to do, however in the near future I will release some "scripts" which will do it all for you.

1. Identify the correct package name

The Facade has all its proxies in projects called "FusionProxy_<Object>Service. Within this project you will find the java classes are split between two packages

  • com.oracle.xmlns : This contains all the standard generated types
  • oracle.demo.pts.fusionproxy.<objectName> : This one contains the proxy itself

Identify the full package name of the proxy for the object you are going to regenerate. In my example here, im going to regenerate the Opportunity object and as you can see the package name is oracle.demo.pts.fusionproxy.opportunities


 2. Delete the contents of the proxy directory.

Shutdown JDeveloper, navigate to the source directory of the proxy project and delete both the src and classes



Startup JDeveloper, navigate to the FusionProxys project , in our case FusionProxy_OpportunityService, you should notice it is now "empty". If it is not the press the refresh button


4.  Regenerate the proxy from scratch

  • Select the project, right mouse click and select new...
  • Select "Web Service proxy" from the Web Services Categories.. If it doesnt show try typing it in the search  dialog
  • Enter the appropriate WSDL Document. This is the Hostname of your service + Endpoint URL. You can get this information from the fusionconfig.properties file.
    E.g. For opportunities it is https://<hostname>/opptyMgmtOpportunities/OpportunityService?wsdl

    Hint: Check it works in a webbrowser first!


  • Next, Wait a bit....
  • For the package name, use the name you identified in step 1, for the Root Package leave it blank
    • Un-Select "Generate As Async"
  • Next
  • Next
  • Select "Don't generate any asynchronous methods"

  • Next 
  • Select "Oracle/wss_username_token_over_ssl_client_policy"
  • Next, then Finish

This will generate the proxy from scratch , just note the generation of the proxy may take some time. 

5. Go to the XJS_Beans project

Within here edit the generateClasses script and modify dummy.oracle.com with your hostname for all rows.

open a shell prompt, navigate to this directory using your shell and execute this script. This regenerates all the JAXB objects..

6. Finally do a Build/Clean All followed by a Build/Make and deploy as normal

Any questions do ask! and yes as I mentioned earlier I plan to create a script to automate all of this. 

Tuesday Jun 10, 2014

Common usecases and techniques when integrating a 3rd party application with Oracle Sales Cloud

Over the last year or so I've see a lot of partners migrating and integrate their applications with Oracle Sales Cloud. Interestingly I'd say 60% of the partners use the same set of design patterns over and over again. Most of the time I see that they want to embed their application into Oracle Sales Cloud, within a tab usually, perhaps click on a link to their application (passing some piece of data + credentials) and then within their application update sales cloud again using webservices.

Here are some examples of the different use-cases I've seen , and how partners are embedding their applications into Sales Cloud,
NB : The following examples use the "Desktop" User Interface rather than the Newer "Simplified User Interface", I'll update the sample application soon but the integration patterns are precisely the same

Use Case 1 :  Navigator "Link out" to third party application


This is an example of where the developer has added a link to the global navigator and this links out to the 3rd Party Application. Typically one doesn't pass any contextual data with the exception of perhaps user credentials, or better still JWT Token.

Techniques Used  

Use Case 2 : Application Embedded within the Sales Cloud Dashboard

Within the Oracle Sales Cloud application there is a tab called "Sales", within this tab its possible to embed a SubTab and embed a iFrame pointing to your application. To do this the developer simply needs to edit the page in customization mode, add the tab and then add the iFrame, simples! The developer can pass credentials/JWT Token and some other pieces of data but not object data (ie the current OpportunityID etc)

 Techniques Used

 Use Case 3 : Embedding a Tab and Context Linking out from a Sales Cloud object to the 3rd party application

In this usecase the developer embeds two components into Oracle Sales Cloud. The first is a SubTab showing summary data to the user (a quote in our case) and then secondly a hyperlink, (although it could be a button) which when clicked navigates the user to the 3rd party application. In this case the developer almost always passes context specific data (i.e. the opportunityId) and a security token (username password combo or JWT Token). The third party application usually takes the data, perhaps queries more data using the Sales Cloud SOAP/WebService interface and then displays the resulting mashup to the user for further processing. When the user has finished their work in the 3rd party application they normally navigate back to Oracle Sales Cloud using what's called a "DeepLink", ie taking them back to the object [opportunity in our case] they came from.

This image visually shows a "Happy Path" a user may follow, and combines linking out to an application , webservice calls and deep linking back to Sales Cloud.

Techniques Used


Use-Case 4 :  Server Side processing/synchronization

This usecase focuses on the Server Side processing of data, in this case synchronizing data. Here the 3rd party application is running on a "timer", e.g. cron or similar, and when triggered it queries data from Oracle Sales Cloud, then it queries data from the 3rd party application, determines the deltas and then inserts the data where required. Specifically here we are calling Oracle Sales Cloud using SOAP/WebServices and the 3rd party application is being communicated to using the REST API, for Oracle Sales Cloud one would use standard JAX-WS WebService calls and for REST one would use the JAX-RS api and perhap the Jackson api for managing JSON objects.. This is a very common use case and one which specifically lends itself to using the Oracle Java Cloud Service as the ideal application server where to host the mediator between the two applications.

 Techniques Used


General Resources

The above is just a small set of techniques and use-cases which are used today. There are plenty of other sources of documentation and resources available on the internet but to get you started here are a few of my favourite places 

JWT Token Security with Fusion Sales Cloud

When integrating SalesCloud with a 3rd party application you often need to pass the users identity to the 3rd party application so that 

  • The 3rd party application knows who the user is
  • The 3rd party application needs to be able to do WebService callbacks to Sales Cloud as that user. 

Until recently without using SAML, this wasn't easily possible and one workaround was to pass the username, potentially even the password, from Sales Cloud to the 3rd party application using URL parameters..

With Oracle Fusion R8 we now have a proper solution and that is called "JWT Token support". This is based on the industry JSON Web Token standard , for more information see here

JWT Works by allowing the user the ability to generate a token (lasts a short period of time) for a specific application. This token is then passed to the 3rd party application as a GET parameter.  The 3rd party application can then call into SalesCloud and use this token for all webservice calls, the calls will be executed as the user who generated the token in the first place, or they can call a special HR WebService (UserService-findSelfUserDetails() ) with the token and Fusion will respond with the users details.



Some more details 

The following will go through the scenario that you want to embed a 3rd party application within a WebContent frame (iFrame) within the opportunity screen. 

1. Define your application using the topology manager in setup and maintenance

2. From within your groovy script which defines the iFrame you wish to embed, write some code which looks like this :

def thirdpartyapplicationurl = oracle.topologyManager.client.deployedInfo.DeployedInfoProvider.getEndPoint("My3rdPartyApplication" )
def crmkey= (new oracle.apps.fnd.applcore.common.SecuredTokenBean().getTrustToken())
def url = thirdpartyapplicationurl +"param1="+OptyId+"&jwt ="+crmkey
return (url) 



This snippet generates a URL which contains

  • The Hostname/endpoint of the 3rd party application
  • Two Parameters
    • The opportunityId stored in parameter "param1"
    • The JWT Token store in  parameter "jwt"

3. From your 3rd Party Application you now have two options

  • Execute a webservice call by first setting the header parameter "Authorization" to the value "Bearer <JWT token>" then calling your webservice of choice. The webservice call will be executed against Fusion Applications "As" the user who execute the process
  • To find out "Who you are" , set the header parameter "Authorization" value to "Bearer <JWT Token>" and then execute the  webservice call findSelfUserDetails(), in the UserDetailsService

For more information 


Thursday Apr 10, 2014

How to restrict data coming back from a SOAP Call

In sales cloud a big positive of the SOAP interface is that lots of related data is returned by issuing a single query, including master-detail data (ie multiple email addresses in contacts) however these payloads can be very very large, e.g. In my system querying single person you get 305 Lines(!), whereas I only want the firstName,LastName and partyId which is 3 lines per record..

Solution

For each findCriteria element you can add multiple <findAttribute> element indicating what elements you want to return. By default if you provide <findAttribute> entries then only those attributes are returned, and this functionality can be reversed by setting the <excludeAttributes> to true.


Example 1 :  only retrieving PersonLastName,PersonFirstName,PartyId

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/applicationModule/types/" xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/">

   <soapenv:Header/>

   <soapenv:Body>

      <typ:findPerson>

         <typ:findCriteria xsi:type="typ1:FindCriteria" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                <typ1:fetchStart>0</typ1:fetchStart>

                <typ1:fetchSize>100</typ1:fetchSize>

<typ1:findAttribute>PersonLastName</typ1:findAttribute>

                <typ1:findAttribute>PersonFirstName</typ1:findAttribute>

                <typ1:findAttribute>PartyId</typ1:findAttribute>

            <typ1:excludeAttribute>false</typ1:excludeAttribute>

         </typ:findCriteria>

      </typ:findPerson>

   </soapenv:Body>

</soapenv:Envelope>

Notes

findAttributes work on the level1 attributes of that findCriteria, the value can be a attribute or an element

If you want to restrict SubElements you can use childFindCriterias for that subelement and then add findAttributes within that

Example 2 :  Only Retrieving PartyId, and within Email element only EmailAddress     

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/applicationModule/types/" xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/">

   <soapenv:Header/>

   <soapenv:Body>

      <typ:findPerson>

         <typ:findControl>

            <typ1:retrieveAllTranslations/>

         </typ:findControl>

         <typ:findCriteria xsi:type="typ1:FindCriteria" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

            <typ1:fetchStart>0</typ1:fetchStart>

            <typ1:fetchSize>100</typ1:fetchSize>

<typ1:findAttribute>PartyId</typ1:findAttribute>

            <typ1:findAttribute>Email</typ1:findAttribute>

            <typ1:excludeAttribute>false</typ1:excludeAttribute>

<typ1:childFindCriteria>

               <typ1:fetchStart>0</typ1:fetchStart>

               <typ1:fetchSize>10</typ1:fetchSize>

<typ1:findAttribute>EmailAddress</typ1:findAttribute>

               <typ1:excludeAttribute>false</typ1:excludeAttribute>

               <typ1:childAttrName>Email</typ1:childAttrName>

</typ1:childFindCriteria>

         </typ:findCriteria>

      </typ:findPerson>

   </soapenv:Body>

</soapenv:Envelope>

Notes

For a childFindCriteria to work you must query it in the parent, which is why “Email” is referenced in a findAttribute on line 14

Thursday Mar 27, 2014

Passing data between apps using URL Query parameters???

If so then you need to be careful about private data.. It can be secure but remember security is only as good as the weakest link.. This article is a nice summary of what's possible , whats secure and what isnt....

https://blog.httpwatch.com/2009/02/20/how-secure-are-query-strings-over-https/

Monday Mar 03, 2014

Developing apps in the cloud? Then you need docs

Over the last couple of months I've been busy working with our documentation people helping them build a set of documentation aimed at partners, specifically around the topic of technical integration with Oracle Sales Cloud. The aim here is to convey our knowledge, and experience of working with partners and come up with some documentation detailing the various use-cases and specifically how it can be implemented.. technically...

All of these documents are now available on http://docs.oracle.com/cloud and specifically the doc I contributed to is the Sales Cloud Use Cases Implementation.

However note that in true Cloud style, this is only the first set of docs in a much larger collection of documents which we [Oracle] are planning to release.

Stay tuned and if you have any suggestions for future doc topics let me know!

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

 

Java

package oracle.fusion.pts.samples.clients;
import com.oracle.xmlns.apps.crmcommon.interactions.interactionservice.Interaction;
import com.oracle.xmlns.apps.crmcommon.interactions.interactionservice.InteractionAssociation;
import com.oracle.xmlns.apps.crmcommon.interactions.interactionservice.InteractionParticipant;
import com.oracle.xmlns.apps.crmcommon.interactions.interactionservice.ObjectFactory;

import com.sun.xml.ws.api.addressing.AddressingVersion;
import com.sun.xml.ws.developer.WSBindingProvider;

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

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

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 {

    @WebServiceRef
    //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
            System.exit(1);
        }
        GregorianCalendar gc=new GregorianCalendar();
        gc.setTimeInMillis(today.getTime());
        // Set Date
        newInteraction.setInteractionStartDate(dtf.newXMLGregorianCalendar(gc));
        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();
        participant.setParticipantId(participantPartyId);
        participant.setParticipantTypeCode("RESOURCE");
        newInteraction.getInteractionParticipant().add(participant);
        // Create  & Add Association, this links it back to Opportunity
        InteractionAssociation association = factory.createInteractionAssociation();
        association.setAssociatedObjectCode("OPPORTUNITY");
        association.setAssociatedObjectUid(opportunityId);
        newInteraction.getInteractionAssociation().add(association);
        // Do the insert
        Interaction result=null;
        try {
            result = interactionService.createInteraction(newInteraction);
        } catch (ServiceException e) {
            e.printStackTrace();
        }
        System.out.println("end - interaction "+result.getInteractionId()+" created");
    }
}

 

XML

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/crmCommon/interactions/interactionService/types/" xmlns:int="http://xmlns.oracle.com/apps/crmCommon/interactions/interactionService/">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:createInteraction>
         <typ:interaction>
            <int:InteractionStartDate>2013-04-27T04:41:11.259-07:00</int:InteractionStartDate>
            <int:InteractionEndDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<!-- CustomerID= SalesParty Customer, also known as TargetPartyId in Opportunity -->
            <int:CustomerId>300000000592745</int:CustomerId>
            <int:InteractionDescription>CTI Detected customer callback </int:InteractionDescription>
            <int:OutcomeCode>SUCCESSFUL</int:OutcomeCode>
<!-- InteractionTypeCode is part of the standard Lookup types -->
            <int:InteractionTypeCode>EMAIL</int:InteractionTypeCode>
            <int:DirectionCode>OUTBOUND</int:DirectionCode>
            <int:MediaItemId>0</int:MediaItemId>
            <int:MediaTypeCode xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
            <int:InteractionParticipant>
<!-- ParticipantId is partyID for contact -->
               <int:ParticipantId>100000000099058</int:ParticipantId>
               <int:ParticipantTypeCode>CONTACT</int:ParticipantTypeCode>
            </int:InteractionParticipant>
            <int:InteractionAssociation>
<!-- AssociatedObjectUid is OPPORTUNITY you want to assocaite this with -->
               <int:AssociatedObjectUid>300000000667205</int:AssociatedObjectUid>
               <int:AssociatedObjectCode>OPPORTUNITY</int:AssociatedObjectCode>
            </int:InteractionAssociation>
         </typ:interaction>
      </typ:createInteraction>
   </soapenv:Body>
</soapenv:Envelope>

 

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 https://blogs.oracle.com/angelo/entry/rest_enabling_oracle_fusion_sales, 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 11.1.1.7
  • 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

Limitations

  • 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 


Material

About

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.

Search

Archives
« May 2015
SunMonTueWedThuFriSat
     
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
      
Today