Generally it goes like this:

<scope>
Do stuff, maybe throw exceptions (or just set status variable to error status)
<faulthandlers>
<catchall>
Process errors. context.%LastError contains your error
</catchall>
</faulthandlers>
</scope>

Check docs for these elements, there are several examples available:

Also, check EnsLib.ebXML.Process.MessageSender for example.

You have compilation error(s). That's why one or more methods are not generated, so instead methods in Ens.BusinessOperation gets called. These methods are returning not implemented error.

To start with 

 Extends (Ens.BusinessOperation, )

should be:

 Extends Ens.BusinessOperation

You can check which exact method has not been generated in Ensemble Event Log.

UPD. [@Rajiv Bhatia] solution is correct, my bad. Should have read your code.

 I feel the whole approach violates the statelessness of a REST architecture?

The request itself is stateless. For example session tracking is okay within REST despite the fact that session exists between requests. Here's how I understand violation of REST statelessness: let's say you have a newsfeed API /news and you return news in chunks of 20 elements. Users are authenticated.

REST way:

  • GET /news/1 - returns first 20 elements
  • GET /news/2 - returns elements 21-40
  • etc.

Not a REST way:

  • GET /news/next - returns first 20 elements
  • GET /news/next - returns elements 21-40
  • etc.

Now, the second approach violates REST principles because request itself - /news/next does not contain enough information to process it. Server should track how much pages each client received, and which page to return next.

To sum up: statelessness in REST means that request itself is enough to determine what do we need to do  with it and request does not require pulling any additional information about previous requests from the same client.

I did not test this approach, but something along these lines can help. The general idea is that SAX parser can validate against the XML schema, and we can use that.

1. Generate schema from your XML enabled classes.

2. Call %XML.Reader:Open method, and provide it with your xml data and schema:

#include %occSAX
set reader = ##class(%XML.Reader).%New()
set reader.SAXSchemaSpec = "/path/to/schema.xsd" // "maybe "file:///path/to/schema.xsd"
set reader.SAXFlags = $$$SAXFULLDEFAULT
set sc = reader.OpenString("<xml/>")
w $System.Status.GetErrorText(sc)


3. sc should contain errors, $$$SAXFULLDEFAULT is defined in %occSAX and contains several possible values:

#; ------------------------------------------------------------------------
#; Bit flags for %XML.SAX.Parser feature selection (flags argument)
#; ------------------------------------------------------------------------
 
#; Specify this value if you want to accept the SAX defaults (see below)
#;
#define SAXDEFAULTS 27
 
#; Specify this value if you want the SAX defaults plus namespaces prefixes/
#define SAXFULLDEFAULT 95
 
#;
#; Specify this bit if you want the parser to perform validation
 
#; http://xml.org/sax/features/validation 
#; On: Report all validation errors. (default) 
#; Off: Do not report validation errors. 
 
#define SAXVALIDATION 1
 
#;
#; Specify this bit if you want the parser to recognize namespaces
 
#; http://xml.org/sax/features/namespaces 
#; On: Perform Namespace processing (default) 
#; Off: Optionally do not perform Namespace processing 
 
#define SAXNAMESPACES 2
 
#;
#; Specify this bit if you want the parser to process namespace prefixes
 
#; http://xml.org/sax/features/namespace-prefixes 
#; On: Report the original prefixed names and attributes used for Namespace declarations 
#; Off: Do not report attributes used for Namespace declarations, and optionally do not report original prefixed names (default)
 
#define SAXNAMESPACEPREFIXES 4
 
#;
#; Specify this bit if you want the parser to perform validation dynamically
 
#; http://apache.org/xml/features/validation/dynamic 
#; On: The parser will validate the document only if a grammar is specified. (http://xml.org/sax/features/validation must be true) (default)
#; Off: Validation is determined by the state of the http://xml.org/sax/features/validation feature
 
#define SAXVALIDATIONDYNAMIC 8
 
#;
#; Specify this bit if you want the parser to recognize schemas
 
#; http://apache.org/xml/features/validation/schema 
#; On: Enable the parser's schema support. (default) 
#; Off: Disable the parser's schema support. 
#define SAXVALIDATIONSCHEMA 16
 
#; Specify this bit if you want the parser to perform full schema checking
 
#; http://apache.org/xml/features/validation/schema-full-checking
#; On: Enable full schema constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation resriction checking are controlled by this option
#; Off: Disable full schema constraint checking (default). 
 
#define SAXVALIDATIONSCHEMAFULLCHECKING 32
 
#; http://apache.org/xml/features/validation/cache-grammarFromParse
#; On: Cache the grammar in the pool for re-use in subsequent parses
#; Off: Do not cache the grammar in the pool (default)
#; If set to true, the http://apache.org/xml/features/validation/use-cachedGrammarInParse is also set to true automatically.
#define SAXVALIDATIONREUSEGRAMMAR 64
 
#; Flags to force SAX not to validate but DO recognize namespaces and prefixes
#define SAXNOVALIDATION $$$SAXNAMESPACES+$$$SAXNAMESPACEPREFIXES

SAXFULLDEFAULT = All flags except SAXVALIDATIONSCHEMAFULLCHECKING.

Maybe try change the flags , but defaults seems to do what you need.

If you actually try this approach can you please post if it works or not?