Extended XQuery for SOA
In a services-oriented architecture (SOA), a business process is implemented as a web service that programs (orchestrates in SOA terminology) other web services. An orchestrator web service is usually coded in a language outside the XML domain (e.g., Java), and in this context XQuery is used only to query and transform data—not to orchestrate other web services. However, here we show how a few extensions to XQuery give it the additional role of web service orchestrator, allowing this XML-domain-specific language to implement all the steps in a complex SOA processes. This article explains the choice of extensions, outlines their implementation for a specific XQuery processor, and shows how extended XQuery was used to create web services to process complex financial data. While web services created in this way are usable within any SOA, they can also act as the highest-level orchestrators in what some authors refer to as SOA lite. The extensions applied here for XQuery work equally well for XSLT 2.0.
Why orchestrate with XQuery?
XQuery (See References 1 and 2) has the potential to become the most applicable language for extracting and transforming data from any source that can be represented as a real or virtual XML document. Its SQL-like syntax is relatively easy to learn and it already has a role in SOA for extracting and transforming data. In its unextended state, XQuery has some capability to orchestrate web services via the XPath 2.0 function doc(uri), which can call the uri using HTTP GET. But XQuery was designed to be extensible by custom functions, which can call code modules external to the processor. Most XQuery processors offer their own API for extension functions and but there is also a pending standardized Java API for XQuery (XQJ) (See reference 3). As we shall show, with a few relatively simple extensions, XQuery can take on the additional role of web service orchestrator, allowing a single XQuery script to implement all the steps in a complex SOA processes. Although other languages can do all this, it is simpler and more efficient to use a XML-domain-specific language like XQuery.
The Relevance for SOA Lite
The label SOA lite has appeared in articles (References 4 and 5), which discuss the levels of sophistication which are possible in a SOA. Lite here refers to a SOA which has all services wrapped in web service interfaces and in which some web services are specially created for orchestration. Therefore, SOA lite need not implement the many so-called governance services, such as for security, discovery, and testing; neither would it involve using an engine to automatically generate the orchestrator web service from a BPEL document. However, SOA lite has the core features of a full SOA, and extended XQuery is ideally suited to create the orchestrator web services for it.
Extending XQuery
What components are required to create XQuery-based orchestrator web services for use in a SOA? And what functions are needed to extend XQuery for this purpose?
Components
The components are simple enough:
- A servlet engine
- An XQuery processor that supports custom extension functions (not to be confused with user-defined functions in unextended XQuery).
- A servlet that calls the XQuery processor (referred to later as the XQuery servlet).
- An XQuery file, with an extension of, e.g., .xqx.
With these components, the sequence of events is as follows:
- A client application posts an XML message to an .xqx url at the servlet engine.
- The servlet engine invokes the XQuery servlet, passing it the url of the XQuery file and the posted XML.
- The XQuery servlet adds any headers and parameters to the posted XML and invokes the XQuery processor, setting the augmented XML as the context document.
- The output from the XQuery processor is streamed back to the client application.
Extension Use Cases
The following use cases for extending XQuery are derived from our experience in processing complex data such as structured finance deals and company financial statements.
- Call another web service. This is the essential use case and, as mentioned, is available using HTTP GET in unextended XQuery. But the facility for HTTP POST, and to set HTTP headers, allows XML messages to be sent to any web service, and this raises XQuery to a new level of usefulness.
- Access HTTP headers from the received XML. For example, if the XQuery is wrapped as a SOAP web service, any SOAPAction header should be extractable. Or the received XML may contain a cookie if it originates from a browser.
- XSchema validation of XML received or sent. Validating XML, received or sent by the orchestrator, using an XSchema is generally a very sensitive test of data structure, data types and referential integrity. This is not equivalent to schema-aware XQuery (SA-XQuery), which assumes the document is validated and uses the in-memory validated instance to offer safer and better-optimized processing. The option to use SA-XQuery is independent of the use of XSchema validation, but if SA-XQuery is required, it makes sense to check first that the received XML will pass validation. It should be noted that XSchema is not suitable for rule-based validation; for example: "for a deal whose type is variable subordination the tranche section must include a time series of points whose detachment value must exceed the attachment value." However, unextended XQuery is ideally suited for this.
Specific Implementation
Our components are Tomcat 5.5 as servlet engine and Saxonica SA 8.9 as XQuery processor. This XQuery processor supports custom extension functions and was easily integrated into a servlet; it also supports XSchema validation, as well as SA-XQuery; and its own library of extension functions includes one for indexing a sequence, a feature equivalent to <xsl:key> in XSLT, which can improve performance massively.
Extensions
Based on the above use cases, the main extensions allow for HTTP POST, getting and setting headers, and XSchema validation. These are best illustrated by some code. Code Sample 1 is the WSDL for a simplified SOAP web service whose input message is a deal structure and whose output defines the status of validating and saving that deal. The message structures are defined in an imported schema. Code Sample 2 shows the important parts of an extended XQuery, which implements the service as defined in the WSDL. The tasks performed are: XSchema validation (extended XQuery); collecting lookup data from another SOAP web service (extended XQuery); rule-based validation and creation of a database-compatible XML structure by user-defined functions (standard XQuery); posting the database-compatible XML to a SOAP service, which updates tables (extended XQuery). These calls are commented in Code Sample 2.
Real-World Example
XML is ideally suited to represent the complex hierarchical data in a structured finance deal. These deals come in many varieties, which are distinguished not just by their structure but by many rules. We were tasked to create web services to manage deals in our database and the client applications were to be a browser, an Excel-add-in or other server. All the web services were created using extended XQuery, and the most complex one performed these tasks
- Calling an authentication web service
- Validating the posted data with XSchema
- Calling several database web services to get the data required for the rule-based validation
- Applying approximately 30 rules
- Transforming the final deal into an XML structure to post to a web service for saving the deal to the database
- Transforming the final deal into an XML structure to post to a SOAP web service for pricing the deal
We had previously implemented a simpler version of the above validation process using a more traditional approach. But using extended XQuery there was less code, it was easier to debug, and it performed better.
Conclusion
We have extended XQuery to give it a new role as web service orchestrator, so that complex web services, involving validation and orchestration, can be implemented entirely in this XML-domain-specific language. Extended XQuery, as applied to the processing of structured finance deals, has greatly simplified the code engineering and given very good performance. We see extended XQuery as suitable for SOA lite or as part of any SOA. These extensions work identically for XSLT 2.0.
References
- W3C XML Query (XQuery) at http://www.w3.org/XML/Query/
- XQuery by Priscilla Walmsley,O'Relly, March 2007.
- XQuery API for JavaTM (XQJ) at http://jcp.org/en/home/index
- Denis Sosnoski at http://www.parleys.com/display/PARLEYS/SOA lite
- Aberdeen Group at http://www.aberdeen.com/summary/report/benchmark/RA_IT_ESB_PK_3170.asp
Acknowledgment
The authors thank Michael Kay of Saxonica for his very prompt and helpful responses to queries on the Saxonica extension API.
2010-08-03 21:48:51 kelly baby- Extended XQuery for SOA
2010-08-03 05:35:43 marryholmes
2010-07-29 15:27:39 henrique1122
2010-07-29 15:26:58 henrique1122- Archery Games
2010-07-28 18:41:36 cairo123
2010-07-26 01:23:27 construction games- I dont think so.
2010-08-03 08:23:37 ricardo quaresma
2010-07-26 01:22:22 construction games- nice
2010-07-23 00:25:18 viviescobar - Pretty good post.
2010-07-22 19:55:31 online casino - Pretty good post.
2010-07-23 00:38:34 viviescobar - My thought
2010-07-22 19:35:55 bloghd86 - H ello
2010-07-21 19:21:16 KarenGuz - business continuity
2010-07-21 05:33:34 jinnie - Nice Information
2010-07-21 02:37:40 FrqHuss - My thought
2010-07-20 02:04:33 bloghd86 - Проститутки
2010-07-19 11:01:28 tomesign - My thought
2010-07-18 18:17:43 bloghd86
2010-07-18 07:33:22 triathlon bike
2010-07-13 11:25:08 kellybaby118
2010-07-12 18:03:11 weEdding
2010-07-12 14:55:44 parkkristian1
2010-07-12 14:53:45 parkkristian1
2010-07-11 07:06:18 tomesign
2010-07-11 06:49:15 tomesign
2010-07-10 13:22:42 Stop Excessive Sweating
2010-07-08 21:32:10 loan calculator
2010-07-08 06:31:36 peterkay
2010-07-08 06:27:34 peterkay
2010-07-06 22:45:35 2 day diet- xml review
2010-07-05 03:08:12 Jamaica willson - Ask Siirleri
2010-07-04 10:20:33 ask siirleri - Aşk Şiirleri Aşk Sözleri
2010-07-04 10:19:19 ask siirleri - software download
2010-07-04 09:02:38 software download - furniture
2010-07-04 02:50:17 furniture prices - Thanks
2010-07-02 18:15:52 Hava Durumu - sesli chat
2010-07-02 15:49:01 seslishe - sesli chat
2010-07-18 01:10:52 miss cathy
2010-07-02 13:49:34 shinsweera
2010-07-01 03:12:17 shinsweera
2010-06-30 07:09:47 shinsweera
2010-06-30 07:08:31 shinsweera
2010-06-30 01:16:58 pinkigreen- safety
2010-06-29 23:12:16 siamsafety - طرب
2010-06-27 02:40:18 ehsas - thanks
2010-06-27 02:36:58 ehsas - interesting
2010-06-25 20:33:54 bilgi rehberi - Helpful
2010-06-22 21:41:19 925cali - Helpful
2010-07-18 03:36:26 moncler - post review
2010-06-21 02:35:51 Jamaica willson - great!
2010-06-20 19:37:31 rayallen
2010-06-18 18:13:04 jannes2- Great item
2010-06-15 22:35:09 gordiano - Marketing
2010-06-15 01:47:48 morevisitor - Marketing
2010-06-16 00:23:46 josepine - Marketing
2010-06-15 01:37:04 morevisitor - XQuery for SOA
2010-06-14 11:12:10 ipvoiper
2010-06-09 13:51:35 suduko.com- extended
2010-06-09 11:52:25 pariuri - Marketing
2010-06-07 13:42:39 morevisitor
2010-06-07 13:35:03 morevisitor- Halloween Super Affiliate
2010-06-07 08:43:02 stvlow - Laura Vandervoort
2010-06-02 09:17:42 Laura Vandervoort - reply
2010-06-02 01:35:11 JuliaAnn - Nicely Explained XQuery for SOA
2010-06-02 00:47:54 Fab Article List
2010-05-27 04:20:03 tonymonta- Thank you
2010-05-25 03:31:32 chris251984
2010-05-22 18:10:02 xuxinunuon- easy
2010-05-20 00:58:25 carmenhariss - Web Design Company
2010-05-19 09:43:10 beginner triathlon program
2010-05-17 03:43:28 jrafique- Table woodworking Plan
2010-05-17 03:40:27 jrafique - www.stopexcessivesweatingproblems.com
2010-05-15 23:47:29 Stop Excessive Sweating - Not good one!!
2010-08-19 03:52:22 nickjohnson12 - lifetime health
2010-05-13 13:51:01 lifetime health
2010-05-12 11:28:50 kooo- nice post
2010-05-10 04:37:49 Jamaica willson - Great!
2010-05-06 14:15:57 timbrookson - Great!
2010-08-13 09:18:13 BloodyBandage - The Cash Code
2010-05-06 05:52:55 ChrisBKE - Great
2010-05-05 22:03:16 gordiano
2010-05-05 09:14:17 Hamsterkäfig
2010-05-03 07:47:16 faraz786g- The Cash Code
2010-05-02 23:50:38 cjroads - chinese shar-pei
2010-08-17 10:13:05 Laura Vandervoort - XML Feed
2010-04-26 08:23:38 bimblegirl - Thanks!!
2010-04-25 08:10:58 henrique1122 - Thanks!!
2010-08-25 23:49:16 poolenclosures - planter fasciitis treatment
2010-04-01 06:43:11 beginner triathlon program - great
2010-03-24 03:50:42 Karlos K. - great
2010-08-13 08:25:30 madame zora - A better way?
2008-02-13 07:08:45 adamretter - A better way?
2010-06-01 06:10:26 echealth - A better way?
2010-05-28 06:36:52 ren999222 - A better way?
2010-08-30 18:01:06 Astalavista Hacking - Placement court terme
2010-08-30 18:00:41 Placement court terme - Placement court terme
2010-09-01 17:14:43 fullbet