SOA 12c – Error while processing audit information. failure due to exception fetching audit xml

While testing in SOA EM Console, if you get below error message for audit trail on launch of flow trace instead showing the actual flow it means that the flow message size is bigger than the default value which is set to 1048576.

Error Message: Error while processing audit information. failure due to exception fetching audit xml

So to view the flow, all you need to do is increase the default size given for audit trial. To do that follow below steps.

Right Click on your node server -> SOA Administration -> Common Properties -> More SOA Infra Advanced Configuration Properties (bottom link) -> Click on ‘Audit Config’ attribute from the list -> Increase the value (eg: 10485760) -> Apply.

This slideshow requires JavaScript.

Hope this is helpful.

Advertisements

Invoking Oracle Fusion Cloud REST services from SOA-CS

In this post I’ll brief about how we can trigger Oracle Fusion ERP Cloud REST services from Oracle SOA-CS.

Let’s take a requirement that to update a fusion cloud database table record. As we aware we won’t have access to cloud database and the only option left to us is making use of REST services provided by oracle.

So let’s go with the specific requirement that to update Expenditure Items table (pjc_exp_items_all). Simply search with the table name in google, you’ll get complete details about the table and columns in it.

This table belongs to Project Portfolio Management, so to search for any REST services available to update tables related to this, go through below Navigation.

Google -> Search for OER (Oracle Enterprise Repository) and open the site -> Select ‘Project Portfolio Management’ tab -> Under ‘Tables & Views’ category, select latest release (Release 13 Update 17b  by the time this post is blogged) -> In the left under REST API click on Project Portfolio Management -> In the page you can see all the available APIs.

Direct link for the same: https://docs.oracle.com/en/cloud/saas/project-portfolio-management/r13-update18a/fapap/api-Expenditure%20Items.html

There select the Expenditure Items API, you’ll be able to see all the methods, select required method (In our case select method ‘PATCH’ which is used to update an expenditure Item) .

Now in the page copy the path to be used for the method to invoke /fscmRestApi/resources/11.13.17.11/projectExpenditureItems/{ExpenditureItemId}

And In the examples, check the sample request and response, which we use to build our schema for input to the REST service.

1.png

Now let’s go into the development.

  • I’ve created a SOA project with BPEL (service defined later).
  • In the BPEL, first let’s create a Schema for the REST service. Make sure the schema attribute names must match with the attribute names given in the sample request, response.

4.PNG

  • In the schema two elements are created one is the primary key of table (ExpenditureItemId) and the other is updatable attribute (ExternalBillRateSourceName) in the cloud table (not all attributes are updatable).
  • Create REST service in the composite file and right click on it and ‘configure SOA WS policy‘ add security policy [oracle/wss_http_token_client_policy] and edit the policy, set csf-key (e.g: CW-key)
  • Put an Invoke activity in BPEL and call the REST service. In the Invoke add properties as given below.

[rest.binding.http.X-HTTP-Method-Override = ‘PATCH’,  rest.binding.http.Accept = ‘application/json’]

  • Create Assign activity and map the required values to the REST input variable.

This slideshow requires JavaScript.

Result: So if you pass ExpenditureItemId, ExternalBillRateSourceName values to REST service, it’ll update the  attribute ‘EXT_OVRD_BILL_RATE_SOURCE_NAME’ with the value coming from ‘ExternalBillRateSourceName’ for the already exist record with given ExpenditureItemId in the ‘pjc_exp_items_all’ table.

Reference (more details about security): http://www.ateam-oracle.com/invoke-fusion-cloud-secured-restful-web-services/

Hope you enjoyed the post!

Translation Error while doing Transformations in SOA

In the Transformation file (.xsl) we map source variable attributes to destination variable attributes.

Let’s say out destination is DBAdapterWriteInputVariable which has 25 columns. In the Transformation file if you map only 15 columns from source to destination (DBAdapterWriteInputVariable) and left the remaining 10 attributes as blank, then at the Transformation step of composite you’ll get this Translation error. This error is because target system is expecting values with respect to its defined schema (25 values) but the transformation file doesn’t map all the values according to the schema (only maps 15), so the error come here.

So all you need to do is, though you are not assigning any values to few attributes, they must be declared (present in source code of XSL file) like <attribute7/> having no value.

To declare them right click on each attribute in design mode which is not present in Source mode, and click on Edit Text and Enter (No need to give any value), so that attribute declaration will be saved which you can see in the source mode.

SOA_TranslationError.png

Hope this is helpful!

WSDL File

Web services have a description language known as WSDL, which is used to describe in a nutshell what the web service does and gives the client all the information required to connect and use the web service

There are two types of WSDL files, They are Abstract WSDL, Concreate WSDL.

Abstract WSDL will be created at design time where as Concrete WSDL will be created after the deployment. Concrete WSDL includes <Binding> and <Service> elements which are not present in abstract WSDL.

WSDL Elements:

  • wsdl: types
  • wsdl: message
  • wsdl: portType
  • wsdl: binding
  • wsdl: service

10

Types: Defines the (XML Schema) data types used by the web service. eg : Employee XML element data type is defined under types.

Messages: Defines the data elements for each operation. eg CreateEmployeeRequest , CreateEmployeeResponse.

PortType: Defines the operations (functionalities) and messages that this web service provides. Eg. Operation – createEmployee , input – CreateEmployeeRequest, Output – CreateEmployeeResponse  is defined in this section.

Binding: Defines the protocol and data format. SOAP binding of the webservice is providing here. Other bindings are ftp, jca etc..

Service: Provides the location (endpoint) where this service is available. https://soadev.orgA.com/services/EmployeeService

Sample WSDL File:

11

 

SOAP and REST

This post covers features of SOAP and REST and basic differences between them.

SOAP

REST

  • SOAP stands for Simple Object Access Protocol
  • It is an XML based web service
  • Adds a layer on top of the application protocols. HTTP is the widely used application protocol.
  • SOAP is considered heavy weight as it provides significant pre-build extensibility in the form of the WS* standards through additional layer.

1

  • Request includes HTTP header, SOAP Envelope (which includes SOAP Header, SOAP Body (which includes XML message))
  • As it has additional layer, it supports attaching files in the request which should be in base64 bit format.
  • It provides more security than REST.
  • REST stands for Representational State Transfer
  • REST typically supports all types of text data formats. Widely used formats are XML and JSON
  • Uses HTTP protocol only. No another layer on top of HTTP protocol.
  • REST is light weight as it leverages HTTP transport and uses all HTTP Action Verbs (POST, GET, PUT, DELETE)

2

 

  • Request includes just HTTP header and XML/JSON message.
  • It doesn’t support attachment of files in the request.
  • REST provides security like token based, but comparatively REST security is less than SOAP.

Sample SOAP Request:

A SOAP Message is encoded as an XML document, consisting of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element is sub element of Body is used for reporting errors.

5.png

 

SOAP Envelope with SOAP Header.

3

Sample SOAP Response:

6.PNG

Sample REST Request in XML:

7

Sample REST Response in XML:

8

Sample REST Request in JSON:

9

Testing of SOAP/REST web service Requests can be done using SOAP UI tool.

XML Basics

XML stands for Extensible Markup Language, which is widely used Message Exchange pattern along with JSON. XML format is similar to HTML, but no predefined tags.

In this post I’ll focus on explaining the concepts for real time usage, instead giving text book definitions.

First let’s see below sample XML code:

2.png

Now let’s see another example where we write employee details for two different organizations.

3.png

In the above example, we have two employee records belong to two different organizations. So we can not use same element name like <employee> for both the organizations. So to overcome this we use the Namespace concept. Here in the example we’ve used two different namespaces for two organizations with the namespace prefixes as ‘orgA’, ‘orgB’ and declared these name spaces at the root element. XML Namespaces provide a method to avoid element name conflicts in an XML document.

If you observe the namespace declaration it seems like an URL, But actually it is  NOT an URL and you can’t open it in browser. You may doubt then why a URL notation is followed for namespace declaration when it is actually not an URL, fact is that it is just a standard that we follow. (If you don’t follow standards you can even declare like xmlns:orgA=“orgA/schemas/Employee”) but is not recommended. 

Now let’s jump into XSD (XML schema document) : 

An XSD document describes the structure of XML document. For the above example we’ll write an XSD document will be as given below.

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emp.org" 
 targetNamespace="http://www.emp.org" elementFormDefault="qualified">
 <xsd:element name="Employee">
 <xsd:complexType>
 <xsd:sequence>
 <xsd:element name="employee" maxOccurs="unbounded">
 <xsd:complexType>
 <xsd:sequence>
 <xsd:element name="name" minOccurs="0" type="xsd:string"/>
 <xsd:element name="id" type="xsd:integer"/>
 <xsd:element name="email" type="xsd:string"/>
 <xsd:element name="phNum" type="xsd:string"/>
 </xsd:sequence>
 </xsd:complexType>
 </xsd:element>
 </xsd:sequence>
 </xsd:complexType>
 </xsd:element>
</xsd:schema>

In the above example if you observe, elements defined as ‘complexType’ are meant that they have child elements. Element <employee> in xml has child elements under it, so its child elements are wrapped in a compleType tag followed by a sequence tag.

4.png

Note: Here in the above image we have element ‘Employee’ and another element ’employee’ under it and then child elements under it. You can directly give all the child elements under element ‘Employee’ instead under element ’employee’.

If you have observed in XSD file there is ‘targetNamespace’ given. Don’t confuse with the Namespace.

  • TargetNamespace is nothing but defining the namespace for all the elements that you define in XML schema.
  • Any element that you define within the schema would be associated with the target namespace. You you’ve defined prefix for the TargetNamesapce then all the elements in the XSD file are associated with the TargetNamesapce using the prefix defined (all element names start with prefixName: followed by element name).
  • If you don’t define target namespace to the Schema, it results in conflicts. So it is advised to give TargetNamesapce always.
  • Each element can have a different namesapce associated with it, but all those elements defined with in the schema should be aligned to a single target namespace. This is just a declaration and make sure you do not use predefined namespace (soap, soap12 etc) for the targetNamespace.

Now let’s see more examples to understand more about XSD:

For the below XML, there are two elements with same name but with different namespace. If you generate XSD out of this XML document using JDeveloper you’ll get an XSD in which you can see only one element is created for both the elements. But this is not correct to use in real time. Better to have a separate declaration for two different <employee> elements in XSD file also.

5.png

You can create an XSD for the above XML as given below also, where two separate elements created though having same name for the elements in XML. This is recommended over above.

6.PNG

In the above example, there are two element with same name (employee), so it is difficult for you to work with this kind of XSD file in SOA. So it is always advisable to have different names. such as employee_orgA, employee_orgB.

7.PNG

 

Now assume if the two element with same name ’employee’ have sub elements with same name and one element has one more extra field, then you can prepare your XSD as given below.

8.png

The source code for the above will be as given below.

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emp.org" targetNamespace="http://www.emp.org"
 elementFormDefault="qualified">
 <xsd:element name="Employee">
 <xsd:complexType>
 <xsd:sequence>
 <xsd:element name="employee_orgA" maxOccurs="unbounded" type="emp_commonType"/>
 <xsd:element name="employee_orgB">
 <xsd:complexType>
 <xsd:sequence>
 <xsd:element name="empCommon" type="emp_commonType"/>
 <xsd:element name="address"/>
 </xsd:sequence>
 </xsd:complexType>
 </xsd:element>
 </xsd:sequence>
 </xsd:complexType>
 </xsd:element>
 <xsd:complexType name="emp_commonType">
 <xsd:sequence>
 <xsd:element name="name" type="xsd:string"/>
 <xsd:element name="id" type="xsd:integer"/>
 <xsd:element name="email" type="xsd:string"/>
 <xsd:element name="phNum" type="xsd:string"/>
 </xsd:sequence>
 </xsd:complexType>
</xsd:schema>

 

Another XSD document for a sample XML document can be created as given below.

9

The above XSD can also be written as given below.

10

 

While loop in SOA

In this post let’s see how we can use While loop in SOA BPEL.

In the example below, we pass input as a number (n) and the response would be sum of all numbers till n (0+1+…n).

  • Create SOA Application (SOA_Appln)
  • Create SOA Project (SOAproj_While)
  • Create BPEL (Synchronous BPEL 2.0)
  • Edit the XSD like below.

 

  • Create two scope variables at BPEL scope level (‘sum’, ‘i’) of type ‘xml schema simple type – int’.

  • Now add Assign activity below receive activity and double click on it. drag an expression and give the value 0 and map it to the scope variable ‘sum’ which we created before. similarly create another expression, give value as 0 and map it to scope variable ‘i’.

  • Now drag the while activity below the Assign1 activity.  Double click on it and give the condition as ($i < $inputVariable.payload/client:input) which means while this condition satisfies the loop will be executed.

  • Now we need to increment the value right, so drag the assign activity inside while loop and double click on it.  drag the expression builder and give the value as $i+1 and map it to scope variable ‘i’. similarly again drag expression builder and give value as $i+$sum and map it to scope variable ‘$sum’ which means we are summing the sum value with the current loop count. (If loop is 4 then sum would be sum+4. Till the loop3, sum will be 1+2+3 =>6. So at loop4 sum would be sum+4 => 6+4 => 10.

  • We are done with the while loop. After the loop exits, now we need to assign the final sum value which we stored in the scope variable ‘sum’ to the output variable. So create an assign activity after while loop and double click on it.

  • The final BPEL will look like below.

  • Deploy the application to SOA server.
  • Let’s test the project. Give input as ‘4’ and the output would be ’10’.

Happy Looping 🙂