Integrating With Fusion Application Using Services (.Net: Web Reference)

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 Web Service Reference for .Net framework.

Prerequisites

.Net development tool such as Visual Studio 2012 needs to be installed and configured.

Implementing Web Service Call

.Net framework is a software framework for Microsoft Windows commonly used by the customers. We can generate a proxy through the Visual Studio by creating Web Service Reference. Do note that you need to create Web Service Reference, not Service Reference; former works with any WSDL based service while latter only works with Windows Communication Foundation (WCF) based services.
To integrate with a service first generate a Web Reference, the "Web Reference Name" entered can then be used to access the objects generated in the code. In the example case the "Web Reference Name" entered was "FusionServiceReference". The following is an example on how use the reference objects generated to find, create and delete a rule by calling a Fusion Applications Web Service:

 

using System;

using System.Net;

using WebServiceReferenceExample1Client.FusionServiceReference;

namespace WebServiceReferenceExample1Client

{

    class Program

    {

        static void Main(string[] args)

        {

            // Get instance of the service to be invoked

            CreditRuleService crs = new CreditRuleService();

            // Set the authentication details to be used for the service call

            NetworkCredential c = new NetworkCredential("username", "password");

            CredentialCache cc = new CredentialCache();

            cc.Add(new Uri(crs.Url), "Basic", c);

            crs.Credentials = cc;

            // Controls whether to send an Authorization header with the request.

            crs.PreAuthenticate = true;

            // Run the test case which includes queries, creates and deletes a rule

            callFindRule(crs);

            callCreateRule(crs);

            Rule rule = callFindRule(crs);

            callDeleteRule(crs, rule);

            callFindRule(crs);

        }

        static Rule callFindRule(CreditRuleService crs)

        {

            Rule result = null;

            try

            {

                // Populate the objects to be used as parameter

                FindCriteria findCriteria = new FindCriteria();

                ViewCriteria viewCriteria = new ViewCriteria();

                viewCriteria.conjunction = Conjunction.And;

                ViewCriteriaRow viewCriteriaRow = new ViewCriteriaRow();

                viewCriteriaRow.conjunction = Conjunction.And;

                viewCriteriaRow.upperCaseCompare = false;

                ViewCriteriaItem viewCriteriaItem = new ViewCriteriaItem();

                viewCriteriaItem.conjunction = Conjunction.And;

                viewCriteriaItem.upperCaseCompare = false;

                viewCriteriaItem.attribute = "Name";

                viewCriteriaItem.@operator = "=";

                string[] ruleNames = new string[1] { "JRAUTIAI_TEST_RULE1" };

                viewCriteriaItem.Items = ruleNames;

                ViewCriteriaItem[] vcis = new ViewCriteriaItem[1] { viewCriteriaItem };

                viewCriteriaRow.item = vcis;

                ViewCriteriaRow[] vcrs = new ViewCriteriaRow[1] { viewCriteriaRow };

                viewCriteria.group = vcrs;

                findCriteria.filter = viewCriteria;

                findCriteria.fetchStart = 0;

                findCriteria.fetchSize = -1;

                FindControl findControl = new FindControl();

                // Call the service with the appropriate parameters

                Rule[] rules = crs.findRule(findCriteria, findControl);

                if (null != rules && rules.Length > 0)

                {

                    result = rules[0];

                    foreach (Rule rule in rules)

                    {

                        Console.WriteLine("ruleId: " + rule.RuleId + " - orgId: " + rule.OrgId + " - name: " + rule.Name);

                    }

                }

                else

                {

                    Console.WriteLine("Rule JRAUTIAI_TEST_RULE1 not found ");

                }

            }

            catch (Exception e)

            {

                Console.WriteLine(e);

            }

            return result;

        }

        static void callCreateRule(CreditRuleService crs)

        {

            try

            {

                // Populate the object to be used as parameter

                Rule rule = new Rule();

                rule.EnabledFlag = true;

                rule.OrgId = 300000000678473;

                rule.OrgIdSpecified = true;

                rule.UsageId = -1001;

                rule.UsageIdSpecified = true;

                rule.StartDate = new DateTime(2012, 1, 1);

                rule.StartDateSpecified = true;

                rule.EndDate = new DateTime(2012, 1, 31);

                rule.EndDateSpecified = true;

                rule.Name = "JRAUTIAI_TEST_RULE1";

                // Call the service with the appropriate parameters

                Rule result = crs.createRule(rule);

                Console.WriteLine("Rule JRAUTIAI_TEST_RULE1 created ");

            }

            catch (Exception e)

            {

                Console.WriteLine(e);

            }

        }

        static void callDeleteRule(CreditRuleService crs, Rule rule)

        {

            try

            {

                // Call the service with the appropriate parameters

crs.deleteRule(rule);

                Console.WriteLine("Rule JRAUTIAI_TEST_RULE1 deleted ");

            }

            catch (Exception e)

            {

                Console.WriteLine(e);

            }

        }

    }

}

The above code does the following:

  1. Get instance of the service to be invoked
  2. Set the authentication details to be used for the service call
  3. Run the test case which includes calls to create, delete and query a rule


Summary

In this article we covered an example using Web Service Reference for .Net framework to integrate with Fusion Applications using web services. In future articles other technologies for invoking Fusion Applications web services will be covered.

References



Comments:

Hi,

When i tried to access the LocationService, i am unable to access the methods. i.e "using WebServiceReferenceExample1Client.LocationServiceReference" is invalid.

Let me know if you need further information.
Thanks,
Sakthi.

Posted by Sakthi on December 30, 2013 at 06:26 AM PST #

As long as your project is "WebServiceReferenceExample1Client" it should work. Are there any build errors ? Can you list the exact steps that you took to create the project & reference ?
--
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/

Posted by Jani Rautiainen on December 30, 2013 at 10:53 AM PST #

Yes. There are some build errors:

Steps:
1. Created a new Project with the name -"WebServiceReferenceExample1Client"

2. Added the web reference - "https://hcm-aufsn4x0***.oracleoutsourcing.com/hcmLocationsV2/LocationService?wsdl"
(POD name is hided with *). FYI:Am able to see the WSLD of above service in browser.

3. Added the namespaces :
using WebServiceReferenceExample1Client.LocationServiceReference;

4. Unable to see methods for this service. So I build the application and got the build error:

" Unable to import WebService/Schema. Unable to import binding 'LocationServiceSoapHttp' from namespace 'http://xmlns.oracle.com/apps/hcm/locations/locationServiceV2/'. Unable to import operation 'updateLocationTranslation'. The datatype 'http://xmlns.oracle.com/apps/hcm/locations/flex/locationextraInfoeff/category/:j_LocationEitCategory' is missing.""

Regards,
Sakthi.

Posted by Sakthi on December 30, 2013 at 11:39 AM PST #

In order for this to work the build errors would need to be resolved. The build error reproduces for the service in question for .Net but not with Java. Presumable there must be some difference on validation / processing of the WSDL / XSD definitions between the two. Please create a SR to resolve this.
While waiting for resolution on the SR you may want to try using HttpWebRequest:
https://blogs.oracle.com/fadevrel/entry/integrating_with_fusion_application_using5

instead of the proxy. This should work as the SOAP envelope is constructed explicitly. Its more work but circumvents the need for generating a proxy ..

--
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/

Posted by Jani Rautiainen on January 02, 2014 at 01:55 AM PST #

Hi Jani,

Its working now. Thanks!

Regards,
Sakthi.

Posted by Sakthi on January 02, 2014 at 04:32 AM PST #

Can you confirm whether your working case is using the "Web Reference", "HttpWebRequest" or both ? I.e. does the original issue still exist and if so did you create a SR for it ?

--
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/

Posted by Jani Rautiainen on January 02, 2014 at 05:17 AM PST #

HttpWebRequest is working fine. But the issue with "Web Reference" is still exist. I will create SR for that.

Regards,
Sakthi

Posted by Sakthi on January 02, 2014 at 05:19 AM PST #

When adding a web reference for Sales Party in Visual Studio it appears to generate 26 errors.

It appears as though all of the Async methods have been generated twice, here is one of the errors.

"Type 'FusionSalesParty.SalesPartyService' already defines a member called 'updateSalesPartyAsync' with the same parameter types W:\Trunk\Web References\FusionSalesParty\Reference.cs"

Posted by guest on February 25, 2014 at 12:48 AM PST #

Comment out the duplicate entries and it should work.
--
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/

Posted by Jani Rautiainen on February 25, 2014 at 12:51 AM PST #

I have already attempted to remove one of the duplicates. The two functions in question are.

public void updateSalesPartyAsync(SalesParty salesParty)
{
this.updateSalesPartyAsync(salesParty, null);
}

or

[System.Web.Services.WebMethodAttribute(MessageName="updateSalesPartyAsync1")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://xmlns.oracle.com/apps/crmCommon/salesParties/salesPartiesService/updateSal" +
"esPartyAsync", RequestElementName="updateSalesPartyAsync", RequestNamespace="http://xmlns.oracle.com/apps/crmCommon/salesParties/salesPartiesService/types/", OneWay=true, Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void updateSalesPartyAsync(SalesParty salesParty) {
this.Invoke("updateSalesPartyAsync1", new object[] {
salesParty});
}

If the first one is commented, the following error is generated when the web service call runs, "Method SalesPartyService.findSalesAccountMyFavoriteSalesAccountsVCAsync can not be reflected.".

If the second method is commented then the following error is generated instead, "There is an error in XML document (1, 2957)."

Here is the code I am using the test the web service call,

SalesPartyService sps = new SalesPartyService();
NetworkCredential nc = new NetworkCredential("username", "password");
CredentialCache cc = new CredentialCache();
cc.Add(new Uri(sps.Url), "Basic", nc);
sps.Credentials = cc;
sps.PreAuthenticate = true;

FindCriteria findCriteria = new FindCriteria();
findCriteria.fetchSize = 2;
findCriteria.fetchStart = 0;

FindControl findControl = new FusionSalesParty.FindControl();

var aq = sps.findSalesAccount(findCriteria, findControl);

foreach (SalesAccount sa in aq)
{
Response.Write(sa.SalesAccountUniqueName + "<br />");
}

Posted by guest on February 25, 2014 at 01:21 AM PST #

You would comment out the former. You stated "I have already attempted to remove one of the duplicates", did you resolve all 26 errors you got or only the one given as example. Are there any compilation errors on the build ?
--
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/

Posted by Jani Rautiainen on February 25, 2014 at 02:43 AM PST #

I have removed them all, they were all very similar errors just with all of the other Async methods. I have removed the former function in all instances and no compilation errors are now generated.

The error received when running the sample code is "Input string was not in a correct format."

Posted by guest on February 25, 2014 at 03:00 AM PST #

It appears as though I was just missing the following line,

findCriteria.findAttribute = new string[] { "SalesAccountUniqueName" };

Thanks for your help.

Posted by guest on February 25, 2014 at 03:09 AM PST #

No problem, so its working for you now ?
--
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/

Posted by Jani Rautiainen on February 25, 2014 at 03:44 AM PST #

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
« April 2014
SunMonTueWedThuFriSat
  
1
2
4
5
6
8
11
12
13
15
16
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today