Learn How to Utilize XQuery Mapping in OSB 12c

In integration scenarios, it is common to encounter situations where the source and target systems have different payload structures. The source system may send a payload with a more extensive set of columns, while the target system may only require a specific subset of these columns, or vice versa. In such cases, it becomes necessary to align the payload structures of the source and target systems to enable effective communication between them. Various integration platforms offer their own mechanisms for mapping elements, but in the case of OSB (Oracle Service Bus), we can utilize XQuery mapping to map the payload elements


Let's use the existing application where Business Service is using Database Adapter to fetch records based on the input parameter CustomerId. 


Input Response having one element that is :  Cust Id


Output Response having multiple Elements like : 

CustId  

CustomerName

City

Designation

LastUpdateDate

LastUpdateLogin

CreationDate

CreatedBy

LastUpdatedBy


Refer to the screenshot of WSDL & XSD structure taken out from Business Services. 




Above part we have discussed is part of Target Payload structure (BusinesServices) Now we have to create Payload Structure For source system


Input Response having one element that is :  EmpId


Output Response having multiple Elements like : 

EmpId

EmpName

EmpCity

EmpDesignation

LastUpdateDate

LastUpdateLogin

CreationDate

CreatedBy

LastUpdatedBy


Now Lets' create XSD based on above elements



Provide XSD  name 




XSD created based on the structure



Create WSDL builder based on newly created XSD 









Now Create Proxy Services based on the WSDL , Provide ProxyName



Select the newly created WSDL 



    Now let's create Xquery for input response first 



Provide XQUERY File Name 




Provide Function Name & add the Source Namespace as shown in the screenshot. 



Select the Input Request element 




Select the TARGET Request Element 



Map the elements from source to Target as shown in the screenshot. 



Run the XQUERY and test it. 




Click on Execute to see the Xquery Transformation






Now create XQUERY Mapping for Outputresponse , as shown in below screenshot.







Provide the function name and NameSpace 





Select Source element in the xquery map as shown in the screenshot. 



Select the Target output Response as shown in the screenshot. 





Click ok to finish it 



Map the source with destination function. 





Try running the XQUERY with some sample payload and see whether transformation happening or not 




Payload transformation happened from Customer to Emp


Open PipleLine ,add Pipeline pair node and Route Node.



Add Replace component in the pipeline and select the boy and map the input xquery transformation.



Select XQUERY Expression and select the XQUERY resource as InputResponse.xqy as shown in the screenshot. 



Now next step is to select the Binding 



Put expression as $body/* and click the radio button "Replace Node Contents" 








Click on Routing node and select Business Service




Drop the replace component in the routing node 



Map the Xquery to the output response as shown in the screenshot.






Put the binding expression $body/*





Now run the project and execute it 


Provide the input to the payload 





Here is the output in different payload structure













Comments

  1. Great post! I really enjoyed reading your perspective on topic. It's evident that you've put a lot of thought into this.
    Fusion financial training in hyderabad

    ReplyDelete

Post a Comment

Popular posts from this blog

REST integration built-in OIC to read Large files with size more than 10MB

Basic Concepts of OAF (Oracle Applications FrameWork )