Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The utilities code is a fixed set of JavaScript that provides some browser compatibility and XML management. This code is delivered in the distribution in the file etc/cxf-utils.js. If you are using the ?js URL handler, it is delivered at the beginning of the response (unless you add ?nojsutils to the URL). If you are generating JavaScript using the tools, it is up to you to copy this file and to use it.

Schema 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:

...

Code Block
javascript
javascript
function testAny1ToServerChalk(url)
{
	var service = new cxf_apache_org_jstest_any_AcceptAny();
	service.url = url;
	var param = new cxf_apache_org_jstest_types_any_acceptAny1();
	param.setBefore("before chalk");
	var anyOb = new cxf_apache_org_jstest_types_any_alts_alternative1();
	anyOb.setChalk("bismuth");
	var holder = new org_apache_cxf_any_holder("uri:cxf.apache.org:jstest:types:any:alts", "alternative1", anyOb);
	param.setAny(holder);
	param.setAfter("after chalk");
	service.acceptAny1(param);
}

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.

.h3 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 accept 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
'false'. CXF may be enhanced to support passing non-described elements to JavaScript at a later time.

Code Block
javascript
javascript

function testAny1ToServerRaw(url)
{
	var service = new cxf_apache_org_jstest_any_AcceptAny();
	service.url = url;
	var param = new cxf_apache_org_jstest_types_any_acceptAny1();
	param.setBefore("before chalk");
	var holder = new org_apache_cxf_raw_any_holder("<walrus xmlns='uri:iam'>tusks</walrus>");
	param.setAny(holder);
	param.setAfter("after chalk");
	service.acceptAny1(param);
}