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

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>

 

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
« July 2015
SunMonTueWedThuFriSat
   
3
4
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