Integrating with Sales Cloud using SOAP web services and REST APIs (Part 2)

This is part 2 of the blog series that covers SOAP and REST integration with Sales Cloud

In part 1, I covered the topic of invoking Sales Cloud SOAP web services from external applications. In this part, I will cover the topic of invoking external SOAP services from Sales Cloud.


2. Invoking external SOAP Web Services from Sales Cloud

Sales Cloud Application Composer allows you to invoke external web services from within Sales Cloud.

In your Sales Cloud instance, use the Navigator to navigate to Tools > Customization >Application Composer.
Invoking an external SOAP web service using Application Composer is three step process

a. Register the external Web service definition in Oracle Sales Cloud

b. Create groovy triggers in Sales Cloud object to Compose a payload in groovy and trigger the registered web service passing the payload

c. Test and Debug web service invocations

2a. Register the external Web service definition in Oracle Sales Cloud

Log in to Sales Cloud using a user that has Sales Administrator access. Create a sandbox (this is required before performing any customization on Sales Cloud). Next, launch Application Composer using the Navigation menu(hamburger menu). Once in Application Composer, click on Web Services in the left navigation bar

For this exercise, let us assume that we are synchronizing an opportunity created in Sales Cloud immediately in an on-premise system. To register a new web service end point, click the ‘Create’ icon, give the reference a name, say’ OpptySync’, provide the WSDL for this external service, and click Read WSDL. Let us assume that this external service uses Username/ password for authentication. Select the ‘Invoke with separate user credentials over SSL’ policy and create a credential key. Save and Close




Note: If your external service is also protected using Oracle Webservice Manager (OWSM) then the security options in the figure above translates to invoking web services protected with one of the following OWSM security policies

o   wss_username_token_over_ssl_service_policy

o   wss_username_token_with_message_protection_service_policy

o   wss11_saml_token_with_message_protection_client_policy

o   wss_saml_token_bearer_over_ssl_client_policy

o   wss11_saml _token_ identity_switch_with_message_protection_service_policy

If the external service is not protected using OWSM then refer the interoperability scenarios at

2b. Create groovy triggers in Sales Cloud object to Compose a payload in groovy and trigger the registered web service passing the payload

The next task is to configure Sales Cloud such that this web service is invoked whenever a new Oppty is created. This is achieved using a trigger written in groovy language. Launch Application Composer if not launched already. Select the Sales Application from the dropdown on the left. The application chosen will vary based on the object that you are choosing. For example, Opportunity is specific to Sales and hence under Sales Application. An account or contact is generic and hence is available under Common

Select the Opportunity Object. Drill down to select ‘Action and Scripts’. Navigate to the triggers tab and click on new.



Create a New trigger on “After Update in Database”. This fires for both create and update. The trigger code is written in groovy as shown below.



Note a few things here. Expand the Show Pallete. This provides you with a list of functions, Fields, keywords and web services that you can easily insert. Remember that this code is getting executed in the context of the current object. So if you want to refer to a particular field of the current opportunity in context, all you have to do is just refer it directly. For example if you want to refer to Country field you can simply search for it in the pallete and insert it (as shown in the screen shot). If you were to do println of the country field, you will see in the logs (how to access – discussed later) the value of the country field in the UI that the end user is viewing.

The same thing applies to web services as well. The web service created will show up in the palette for inserting into the groovy code and passing all necessary values from the UI (see image below)


No XML manipulation or SOAP Payload construction is done at the groovy level. The translation from Groovy Maps to SOAP payloads is taken care of by Sales Cloud infrastructure using the web service definition that you created in the previous step.

  def userEmailAddress = adf.context.getSecurityContext().getUserProfile().getBusinessEmail().toLowerCase()
  println('Entering Update Oppty')
  println('Building Oppty payload')
  def OpptyWebSvcPayload =
      CreatedBy :nvl(userEmailAddress, ''),
      CurrencyCode :nvl(CurrencyCode, ''),
      LastUpdatedBy :nvl(userEmailAddress, ''),
      Name :nvl(Name, ''),
      WinProb :nvl(WinProb, ''),
      Revenue :nvl(Revenue, ''),
      PrSrcNumber :nvl(PrSrcNumber, ''),
        LeadNumber :nvl(LeadNumber, ''),
println('Invoking Oppty Update in External System with payload: '+ OpptyWebSvcPayload)
  def resp = adf.webServices.CreateOppty.process(OpptyWebSvcPayload)
  if (resp == null) 
    throw new Exception('Null response from web service')
  println('Oppty Update response received')
  println('Response: ' + resp.toString())
  println('Failed to Sync Oppty due to: '+ e.getMessage())

A highly simplified version of this groovy code is presented below. The simplicity is for easy understanding. The complete Oracle Sales Cloud groovy scripting reference guide is available here. Additionally some best practices for writing groovy code in Sales Cloud App composer can be found here

2c. Test and Debug web service invocations

Since the above trigger was written to fire on create/update of an opportunity, no additional custom UI element is required in Sales Cloud to initiate the integration. Instead of a trigger, a custom UI widget such as a button can be created and configured to execute the same groovy code. I’ll proceed with the assumption that we are using a trigger and hence to test the web service invocation, I have to merely create a new opportunity on Sales Cloud and click Save.


To debug, you can use print statements in groovy code to print values during the trigger execution. These print statements can be viewed through the Application Composer itself. Navigate to Runtime messages as shown in the screen below. Ensure that you are in the ‘Sales’ application and ensure that the logging flag is checked. As you create or edit opportunities, you should see the log messages.


Note: In addition to invoking SOAP services during record edit or create, Sales Cloud can also raise events that integration systems can consume. This is covered in another blog which is not part of this series –


This concludes the topic of making outbound SOAP invocations from Sales Cloud.


  1. Hi,
    Sales Cloud’s Object workflow has call external web service also,in send outbound message part,but no security configure form,why?if external web service need user and password,how can I configure security?

    • Arvind Srinivasamoorthy says:

      Object workflow is not recommended for outbound calls for several reasons. Please use the methods described above. I’ve also updated the blog recently with more details.

  2. hi

    i have deployed my webservice in a Weblogic . I am getting a time out exception when reading WSDL from app composer

    any idea why?

    • Marco Fanti says:

      Could be for many reasons. To me happened the same because weblogic was requiring connections over TLS 1.2, while app composer tries with TLS 1.0.

      You can see which versions of TLS your weblogic is supporting testing your domain from this website:

      Then it turns out your weblogic is not supporting TLS 1.0, you have to restart it with the correct parameter

  3. Frank Cannon says:

    When using the HTTPClient example, I get the following error when the code is validated:

    Error: Security Violation(s)
    JBO-25152: Calling the constructor for class is not permitted.
    JBO-25152: Calling the constructor for class groovy.util.XmlParser is not permitted.

    Can you provide a solution?

    Thank you

    • Arvind Srinivasamoorthy says:

      As updated in the post above, Oracle is revamping REST related features. The use of class in groovy scripts is blocked. So please stay tuned for the new features in upcoming updates. This section will be live again after the new set of features are available.

Add Your Comment