Integrating With Fusion Application Using Services (Perl: HttpRequest)

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 HTTP::Request for Perl.

Prerequisites

The reader is expected be familiar with the Perl and as such the details on creating the development environment and basic development are not covered.

Implementing Web Service Call

With HTTP::Request we are directly constructing and processing the XML for the SOAP:

#!/usr/bin/perl -w
 
use strict;
 
use LWP::UserAgent;
use HTTP::Request::Common;
use MIME::Base64;
 
my $ua = LWP::UserAgent->new(agent => 'perl post');
 
# Construct xml payload, which is used to invoke the service. In the example case it is a "hard coded"
my $envelope = <<END;
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <findRule xmlns="http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/types/">
      <findCriteria>
        <fetchStart xmlns="http://xmlns.oracle.com/adf/svc/types/">0</fetchStart>
        <fetchSize xmlns="http://xmlns.oracle.com/adf/svc/types/">-1</fetchSize>
        <filter xmlns="http://xmlns.oracle.com/adf/svc/types/">
          <group>
            <upperCaseCompare>false</upperCaseCompare>
            <item>
              <upperCaseCompare>false</upperCaseCompare>
              <attribute>RuleId</attribute>
              <operator>=</operator>
              <value>300000000851162</value>
            </item>
          </group>
        </filter>
        <excludeAttribute xmlns="http://xmlns.oracle.com/adf/svc/types/">false</excludeAttribute>
      </findCriteria>
      <findControl>
        <retrieveAllTranslations xmlns="http://xmlns.oracle.com/adf/svc/types/">false</retrieveAllTranslations>
      </findControl>
    </findRule>
  </soap:Body>
</soap:Envelope>
END
 
# Construct the base 64 encoded string used as the credentials for the service call
my $credentials = encode_base64('username:password');
my $url = 'https://host:port/icCnSetupCreditRulesPublicService/CreditRuleService';
 
 
# Create new POST request
my $req=new HTTP::Request 'POST',$url;
 
# Configure the request to use basic authentication, with base 64 encoded a user name and a password to invoke the service.
$req->header('Authorization' => "Basic " . $credentials);
 
# Set the SOAP action to be invoked; while the call works without this the value is expected to be set based on standards
$req->header('SOAPAction' => 'http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/findRule');
 
# Configure the request content type to be xml, HTTP method to be POST and set the content length
$req->header('Content-Type' => 'text/xml;charset=UTF-8');
 
# Write the xml payload to the request.
$req->content($envelope);
 
# Call the service
my $response=$ua->request($req);
 
# Process the response, in this example we simply print out the response
print $response->error_as_HTML unless $response->is_success;
print $response->as_string;

  • Construct xml payload, which is used to invoke the service. In the example case it is a "hard coded" string which is encoded to UTF-8 byte array to be passed to the request
  • Construct the base 64 encoded string used as the credentials for the service call
  • Create POST request for the service
  • Configure the request content type to be xml, to use basic authentication with base 64 encoded credentials
  • Set the SOAP action to be invoked; while the call works without this the value is expected to be set based on standards
  • Write the xml payload to the request
  • Call the service
  • Process the response, in this example we simply print out the response

Summary

In this article we covered an example using HTTP::Request for Perl 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
« July 2015
SunMonTueWedThuFriSat
   
2
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