xquery version "1.0"; (: Namespace declarations and user-defined functions not shown. :) (: The extension namespaces prefixes are 'schema' and 'postDocument':) { (:below - context /root is constructed by the XQuery servlet and contains the posted XML, HTTP headers, any parameters and the host url. :) let $hosturl := /root/requestInfo/hosturl let $posted-xml-msg := /root/posted-xml/soap-envelope:Envelope/soap-envelope:Body/obx:validate_deal_in_msg (:below - extension function creates a schema object:) let $schema := schema:new($hosturl, "/schemas/deal_services.xsd") (:below - extension function uses $schema to validate the XML ($posted-xml-msg wrapped as a document node). :) let $schema-validation-out := schema:validate($schema, document { $posted-xml-msg }) return if(exists($schema-validation-out/exception)) then user-defined:output-errors($schema-validation-out) else let $deal-data := $posted-xml-msg/obx:deal (:below - construct a SOAP message.:) let $lookup-data-in := (:below - extension function creates a new document to POST. You can set its headers if required.:) let $document-to-post := postDocument:new() (:below - extension function attaches XML message $lookup-data-in to $document-to-post and POSTs it to /soap/get_lookup_data.xsql at $hosturl.:) let $lookup-data-out := postDocument:post($document-to-post, $hosturl, "/soap/get_lookup_data.xsql", $lookup-data-in) (:below - call a user-defined function.:) let $rule-based-validation-out := user-defined:rule-based-validation-erorrs($deal-data, $lookup-data-out) return if(exists($rule-based-validation-out/exception)) then user-defined:output-errors($rule-based-validation-out) else let $deal-data-for-database-in := { user-defined:transform-for-database($deal_data) } let $document-to-post2 := postDocument:new() let $deal-data-for-database-out := postDocument:post($document-to-post2, $hosturl, "save_deal.xsql", $deal-data-for-database-in) return $deal-data-for-database-out } (: Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. All rights reserved. :)