Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Access XML in java embedding in oracle SOA 11g

User_EWWE4Feb 1 2021

We are using SOA 11g. 11.1.1.7.0
I am trying to access the XML in java embedding instead of single xml element. But it is showing only values without tags when i print in logs.
I have variable "inputName" string that has the data as below
<inputName xmlns:def="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="def:string"><orderactivity><order><ordersource>EDI</ordersource><ordertype>NA SPECIAL</ordertype><ponum>151255553384-5000244</ponum><status>A</status><orderdate>01/25/21</orderdate><customernum>5000244</customernum><shiptoloc>5000244</shiptoloc><custpo>151253384</custpo><jobname>665619208 test</jobname><fob>PP</fob> </order></orderactivity>]]></inputName></inputName>

I tried to get this variable in java embedding as below
try{
XMLElement inputParam = (XMLElement)getVariableData("inputName");
String input_str = inputParam.getTextContent();
addAuditTrailEntry("Input String is " + input_stream);
}catch(Exception exc) {
addAuditTrailEntry(exc);
}

This is what it prints in logs. it is printing all the values without xml tags.
Input String is EDINA SPECIAL151253384-5000244A01/25/2150002445000244151253384665619208 test

How to access the whole xml payload in java embedding. Am looking at the desired output as below with XML tags.
<inputName xmlns:def="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="def:string"><orderactivity><order><ordersource>EDI</ordersource><ordertype>NA SPECIAL</ordertype><ponum>151255553384-5000244</ponum><status>A</status><orderdate>01/25/21</orderdate><customernum>5000244</customernum><shiptoloc>5000244</shiptoloc><custpo>151253384</custpo><jobname>665619208 test</jobname><fob>PP</fob> </order></orderactivity>]]></inputName></inputName>

Comments

Frank Kulash

Hi,

Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the exact results you want from that data, so that the people who want to help you can re-create the problem and test their ideas.

Explain, using specific examples, how you get those results from that data.

Always say what version of Oracle you're using (e.g. 11.2.0.2.0).

See the forum FAQ:

Use the analytic ROW_NUMBER function to assign numbers 1, 2, 3, ... to each row, with a separate series for each worker and date.  Each distinct combination of worker and assigned number will result in a row of output.

CarlosDLG

You will usually get quicker and more accurate answers if you post create table statements and inserts with some sample data, along with an explanation of the specific problem you are facing.

Here is one way to do it:

WITH test_data as

(

SELECT 'Project_A' project,'John' worker,date '2016-05-23' the_date FROM DUAL union all

SELECT 'Project_A','Mary',date '2016-05-23'  FROM DUAL union all

SELECT 'Project_A','Mary',    date '2016-05-24' FROM DUAL union all

SELECT 'Project_A','Steve',date '2016-05-24' FROM DUAL union all

SELECT 'Project_A','Mary',date '2016-05-25' FROM DUAL union all

SELECT 'Project_A','Mary',date '2016-05-26'  FROM DUAL union all

SELECT 'Project_B','John',date '2016-05-23' FROM DUAL union all

SELECT 'Project_B','Steve',date '2016-05-24' FROM DUAL

)

select worker,c23,c24,c25,c26 from

(

  SELECT t.*, dense_rank() over (PARTITION BY worker ORDER BY project) AS rn

  FROM test_data t

)

pivot

(

  MAX(project) FOR the_date in (date '2016-05-23' AS C23,date '2016-05-24' AS C24,date '2016-05-25' AS C25,date '2016-05-26' AS C26)

)

ORDER BY worker;

Results:

WORKERC23C24C25C26
JohnProject_A
JohnProject_B
MaryProject_AProject_AProject_AProject_A
Steve Project_A
Steve Project_B
Paulzip

You cannot dynamically generate your columns (e.g. generate your column names based on the data) without using special techniques (dynamic SQL), SQL has to have static columns at execution time.

Here's another way to do it.

select worker, d1, d2, d3, d4

from

(

  select project, worker,

         dense_rank() over (order by the_date) as date_rank,

         dense_rank() over (order by project) as project_rank

  from test_data t

)

pivot (

  max(project)

  for date_rank in (1 as D1, 2 as D2, 3 as d3, 4 as d4)

)

order by worker

WORKERD1D2D3D4
JohnProject_A
JohnProject_B
MaryProject_AProject_AProject_AProject_A
SteveProject_A
SteveProject_B
1 - 3

Post Details

Added on Feb 1 2021
0 comments
46 views