Service Bus 12c – Using XQuery map

In this post, you will learn to create and use XQuery maps in message flow using the same Service Bus project used in previous posts.


And here we are creating XQuery map for Address transformation. The Source WSDL CustomerPS.wsdl and Target WSDL AddrValidationService.wsdl  are available here and here respectively. Make sure that you have these WSDLs copied in your project before proceeding with XQuery map creation.

Creating XQuery map:

Right click XQueries folder in XYZCustomer project and select New -> XQuery File ver1.0 to create new XQuery. Give both file and function name as AddrToAddrBSInput as shown below.


Click + icon to add Source parameter and give name as inputAddr.


Click pencil icon for Sequence Type to bring up Function Parameter Type window. Click browse icon and select Customer element in CustomerPS.wsdl as shown below. Here Customer element has address fields.


Click OK and retain default values for all the other properties in Function Parameter Type window as shown below.


Go back to Create XQuery Map window by clicking OK twice. Now click pencil icon for Target to bring up Function Result Type window. Click browse icon and select addrval_input element as shown below. Observe that the WSDL being used is AddrValidationService.wsdl.


Click OK thrice to bring up the Transformation editor and also do the initial mapping of attributes as shown below. You can map the fields by connecting Source and Target elements directly.


Drag concat function from Components -> XQuery Functions -> String Functions into Mappings swim lane. Connect Address2 and Address3 input elements to this function as shown below, as Target element expects concatenation of all address lines.


Address Validation service expects address lines with ‘,’ as delimiter, so go to XQuery Source tab and modify concat function as shown below.


Testing XQuery map:

It’s always advisable to test your XQuery to verify that mapping is working as expected. So right click XQuery file in XYZCustomer project and select Run XQuery.



Click List of variables button (highlighted above) to bring Edit Variable screen and select options as shown below.  This will generate the sample inputs automatically.


Click save icon and give file name as SampleCustomerInput.xml and click Add to Sequence.


Click OK and go back to Run XQuery screen. Give Target file name as AddrServiceInput by clicking Save icon.


Click Run and verify output of XQuery map to see mapping is working as you expected. You can observe that all address elements in Source concatenated and assigned to single element address_line in Target. You can also verify sample Source and Target files created in your XQueries folder.


Using XQuery map:

Drag Assign activity into Service Callout from Message Processing or place it at any other place in your Message Flow depending on where you want to use this transformation.


In Properties tab, select XQuery Resources for Value property.


In Expression Builder, click Browse icon and select the XQuery mapping.


Click OK. Use the following steps to set value for Binding property.



Click OK twice and set addrReqBody as the value for Variable property. This variable will contain the transformed value of address and can be used in your message flow later.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 379 other subscribers

Enter your email address to follow this blog and receive notifications of new posts by email.

%d bloggers like this: