Integrating With Fusion Application Using Services (Python: suds)

Fusion Applications provides Web services that allow external systems to integrate with Fusion Applications. There are two types of services: ADF services and composite services. ADF services are created for a logical business object and provide functionality to access and manipulate these objects. The composite services are mostly process oriented and provide an orchestration of multiple steps.  

Information about the web services provided by Fusion Applications is hosted in Oracle Enterprise Repository (OER). The information provided by OER can be used to understand the functionality provided by the service and how the service can be called.

This series of articles describes how one can invoke SOAP web services provided by Fusion Applications using various technologies. In this article we will cover how to invoke a Fusion Application web service using Suds for Python.

Prerequisites

The reader is expected be familiar with the Python and as such the details on creating the development environment and basic development are not covered. Suds provides convenience methods based on the WSDL that allow building the SOAP envelope and client to call the service. To setup an environment download and install the following:

  • If not already installed download per-requisite setuptools and install by issuing "python setup.py install"
  • Download Suds and install by issuing "python setup.py install"

Implementing Web Service Call

Python is a widely used programming language; it is used e.g. by Oracle JDeveloper when creating domains. There are various tools that can be used to make the call, for demonstration purposes we use suds:

import base64
from suds.client import Client
 
username='username'
password='password'
 
# Construct the base 64 encoded string used as the credentials for the service call
credentials = base64.encodestring('%s:%s' % (username, password))[:-1]
authorization =  "Basic %s" % credentials
url = 'https://host:port/icCnSetupCreditRulesPublicService/CreditRuleService?wsdl'
 
# Configure the request content type, SOAP action and authentication in header
authenticationHeader = {
    "SOAPAction" : "http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/findRule",
    "Content-Type" : "text/xml;charset=UTF-8",
    "Authorization" : authorization }
 
# Create new client
client = Client(url=url, headers=authenticationHeader)
 
# Populate the objects to be used as parameter
findCriteria = client.factory.create('ns4:FindCriteria')
findControl = client.factory.create('ns4:FindControl')
viewCriteria = client.factory.create('ns4:ViewCriteria')
viewCriteriaRow = client.factory.create('ns4:ViewCriteriaRow')
viewCriteriaItem  = client.factory.create('ns4:ViewCriteriaItem')
 
viewCriteriaItem.upperCaseCompare = "false";
viewCriteriaItem.attribute = "RuleId";
viewCriteriaItem.operator = "=";
viewCriteriaItem.value = "300000000851162"
 
viewCriteriaRow.upperCaseCompare = "false"
viewCriteriaRow.item.append([viewCriteriaItem])
viewCriteria.group.append([viewCriteriaRow])
 
findCriteria.fetchStart = "0"
findCriteria.fetchSize = "-1"
findCriteria.excludeAttribute = "false"
findCriteria.filter = viewCriteria
 
findControl.retrieveAllTranslations = "false"
 
# Call the service
rule = client.service.findRule(findCriteria, findControl)
 
# Process the response, in this example we simply print out the response
print rule 

The above code does the following:

  1. Construct the base 64 encoded string used as the credentials for the service call
  2. Configure the request header with the content type, SOAP action and authentication information
  3. Create new client based on the WSDL
  4. Populate the objects to be used as parameter
  5. Call the service
  6. Process the response, in this example we simply print out the response

Summary

In this article we covered an example using Suds for Python to integrate with Fusion Applications using web services. In future articles other technologies for invoking Fusion Applications web services will be covered.

References

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow us on twitter Fusion Applications Extensibility, Customizations and Integration forum Fusion Applications Dev Relations YouTube Channel
This blog offers news, tips and information for developers building extensions, customizations and integrations for Oracle Fusion Applications.

Search

Categories
Archives
« May 2015
SunMonTueWedThuFriSat
     
1
2
4
6
8
9
10
11
13
14
16
17
18
20
22
23
24
27
29
30
31
      
Today