Structure of the Code
The Schema code generates one object for each 'bean' used in your service. This code is organized by XML Schema. The code for each schema starts with a comment like:
This is very simple type, derived from the return part of a Document/Literal service. It has one piece of data in it, called 'responseType'. Note that the code style here is to define getters and setters over 'private' properties. The code does not go to elaborate lengths to make the properties private; it just puts an _ on the front of the names.
The code for a service starts with a comment, followed by a constructor for the per-service object:
There are two important properties defined here: url and synchronous.
- Stick with Mozilla/Firefox and sign the code.
- Modify the utils to use some of the common workarounds that permit cross-scripting in some browsers in some circumstances.
Synchronous and Asynchronous processing
The code generator generates a function for each operation. Unless the operation is one way, the function will take two callback parameters, plus the parameters for the operation itself. The first two parameters are the success callback and the error callback. OneWay operations have no callbacks; they are "fire and forget."
The error callback will be called only when the server responds with an HTTP error status. It will be called with two parameters: the HTTP status number and the HTTP status text.
fault information as a third parameter to the error callback.
Understanding the Parameters of Operation Functions
If you have a choice in the matter, and you are using Document/Literal, the present author recommends bare as opposed to wrapped methods. This pushes all the type management from the front end (JAX-WS or Simple) to the data binding (JAXB or Aegis). The data bindings offer much clearer configuration control over namespaces, minOccurs, and such than the frontends.
Examples of Calling Services
A Document/Literal/Bare Service
The present author finds that, at least for JAX-WS, BARE has a lot to recommend it, as it avoids surprising interactions between JAX-WS and JAXB.
xs:any Example: Using a Described Type
The following function calls a Document/Literal/Bare method. The bare parameter element is declared as:
The target namespace for this schema is uri:cxf.apache.org:jstest:types:any.
This particular xs:any allows any single XML element from some namespace other than the target namespace of the schema containing 'acceptAny1'.
(Note that JAXB only supports xs:any for ##other, and interprets it to forbid unqualified elements. If you need more flexibility, consider
another data binding.)
The WSDL contains a reference to another schema, with target namespace uri:cxf.apache.org:jstest:types:any:alts. That namespace includes
It fills in the slots for the simple before and after elements.
For the xs:any element, it creates an object of type org_apache_cxf_any_holder. This type, defined in cxf-utils.js, holds an object for an element
defined in the WSDL's schemas. To construct one, you supply the URI and local names of the element, and then the value. For built-in types, use the XML Schema URI
(http://www.w3.org/2001/XMLSchema) and the name of the type (e.g. 'string').
What if your xs:any calls for more than one item? You supply an array of holders, since each holder could be some different element.
xs:any Using Raw XML
CXF also allows you to provide the XML yourself. The XML you provide must be valid. If the elements are qualified, you must
define the namespace definitions with appropriate xmlns attributes. Here is an example. Note in this example that the
element is qualified; it lives in the uri:iam namespace. JAXB does not permit unqualified elements (at least in the current version
of the reference implementation that CXF uses).
If your xs:any accepts multiple elements, you supply a single holder with a XML fragment containing multiple elements.
Note the use of org_apache_cxf_raw_any_holder to pass the XML to CXF.
Also note that CXF does not support raw XML passed from the server to the client. In a return value, you will always find a
org_apache_cxf_any_holder. However, the raw holder has a 'raw' property with value 'true', and the non-raw holder has a 'raw' property with value