Call an External SOAP Web Service from Groovy with Message Protection

This example shows how to create a connection to an external, secured SOAP web service and call the web service from a Groovy script used in Application Composer. The web service is secured with message protection.

For this example, the web service is used to calculate a custom field's default value.

The following table summarizes key decisions for this scenario:

Decisions to Consider

In This Example

What name will you use for the web service connection?

mathsws

What is the URL of the Web Services Description Language (WSDL) file that you will use?

http://external-hosted:7101/MathsWS-Model-context-root/Wss11UsernameWithMessageProtectionSecurity?wsdl

This WSDL file specifies the desired message protection security scheme.

Note: The URL shown here's an arbitrary example. You must obtain the real WSDL URL from the service provider.

Which credential key will you use?

mylogin

Where will the web service be called from?

From a Groovy script expression used to calculate a custom field's default value.

Which web service method will be called from the Groovy script?

getSum

This method returns the sum of two integer argument values.

What will the server encryption alias name be?

serverenckey

Is it required to ignore the time stamp in the response from the web service?

Yes.

To ignore the time stamp, you select the Disable Time Stamp Verification check box. This may be required to address interoperability issues.

To call a web service from a Groovy script that's secured with message protection, complete the following tasks:

  1. Create the web service connection.

  2. Add the web service call to the Groovy script, and check whether the call succeeds.

  3. Contact the administrator to resolve runtime exceptions.

  4. Re-create the web service connection.

  5. Verify that the web service call succeeds.

Prerequisites

Verify that you have completed the following prerequisite steps:

  1. Get details of the WSDL URL and the user credentials to use from the web service provider.

  2. Get the server encryption certificate and the Certificate Authority (issuer) certificate from the web service provider.

  3. Create a custom field for an object that has a calculated default value.

  4. Prepare the Groovy script for the expression used to calculate the field's default value. The Groovy code must prepare the argument values, which in this example are two values that are summed.

Creating the Web Service Connection

When you create a web service connection, you specify a name for the web service, the URL of the WSDL file, and the security scheme settings. The name is simply an identifier that's used in the list of web services in the Expression Builder in Application Composer.

  1. In Application Composer, select Web Services in the Common Setup pane.

  2. On the Web Services page, click the New icon, then click SOAP.

  3. On the Create SOAP Web Service Connection page, enter mathsws in the Name field.

    The name must not include periods.

  4. Enter http://external-hosted:7101/MathsWS-Model-context-root/Wss11UsernameWithMessageProtectionSecurity?wsdll in the WSDL URL field, and click Read WSDL.

  5. Click the New Key icon next to the Credential Key field.

  6. In the Create Key dialog box, enter a name in the Credential Key field, in this example, mylogin, enter the user name and password credentials supplied by the web service provider, and click OK.

  7. Select Disable time stamp verification so that the time stamp in the response header from the web service is ignored.

  8. Click Save and Close.

    The web service connection is created and the name and WSDL URL are listed on the Web Services page.

Adding the Web Service Call to the Groovy Script

In the Expression Builder dialog that you see when you create or edit Groovy scripts, there is a Web Services tab that lists the web services for which you have created a connection. For each web service you can include calls to the available methods in your Groovy script.

  1. In Application Composer, edit the custom field that uses the expression that will contain the web service call.

  2. Click the Expression Builder icon.

  3. In the Expression Builder dialog, select the Web Services tab.

  4. Select mathsws from the Web Services list.

  5. Select getSum from the Functions list.

  6. Position the cursor at the place in the script where you want to insert the web service call.

  7. Click Insert to insert the code to call the web service method.

  8. Update the script so that two integer values are provided as arguments for the web service call.

  9. Click Submit.

  10. Verify that the web service call succeeds; in this example the custom field should have the expected default value.

Contacting the Administrator to Resolve Runtime Exceptions

The web service call may fail due to a number of exceptions including path certification, bad encryption, and policy enforcement exceptions. You must create a service request for your administrator to resolve the issues.

  1. Create a service request for your administrator:

    1. Retrieve the server encryption certificate and the Certificate Authority (issuer) certificate from the web service provider.

    2. Attach the server encryption certificate and the issuer certificate to the service request, and include the WSDL location, and error details.

    3. Submit the service request.

    The administrator will add the server encryption certificate and the issuer certificate into the Oracle Fusion CRM trust store. The administrator also creates an alias for the server encryption key, which you will use in the next task.

  2. Wait until your administrator informs you that the certificates have been imported, and that the server encryption alias has been created, and then close the service request.

Recreating the Web Service Connection

After your administrator has resolved runtime exceptions, you must re-create the web service connection and this time specify the server encryption key alias supplied by the administrator.

  1. In Application Composer, select Web Services in the Common Setup pane.

  2. On the Web Services page, select the web service connection you created previously, and click the Delete icon.

  3. On the Web Services page, click the New icon, then click SOAP.

  4. On the Create SOAP Web Service Connection page, enter mathsws in the Name field.

  5. Enter http://external-hosted:7101/MathsWS-Model-context-root/Wss11UsernameWithMessageProtectionSecurity?wsdll in the WSDL URL field, and click Read WSDL.

  6. Click the New Key icon next to the Credential Key field.

  7. In the Create Key dialog box, enter a name in the Credential Key field, in this example, mylogin, enter the user name and password credentials supplied by the web service provider, and click OK.

  8. Select Disable time stamp verification so that the time stamp in the response header from the web service is ignored.

  9. On the Create SOAP Web Service Connection page, enter serverenckey in the Outgoing Encryption Key field.

  10. Click Save and Close.

    The web service connection is created and the name and WSDL URL are listed on the Web Services page.

Verifying that the Web Service Call Succeeds

After you have re-created a web service connection, you must verify that the call to the web service succeeds.

  1. Make sure that the Groovy script contains the code to call the web service.

  2. Verify that the web service call succeeds; in this example the custom field should have the expected default value.