...
Code Block | ||||
---|---|---|---|---|
| ||||
function errorCallback(httpStatus, httpStatusText) { globalErrorStatus = httpStatus; // integer HTTP status globalStatusText = httpStatusText; // Textual HTTP status } function successCallback(responseObject) { // the parameter is an object of the type declared for the // method. globalResponseObject = responseObject; } function compliantTest(url) { var intf; // class for the service. intf = new org_apache_cxf_javascript_fortest_SimpleDocLitBare(); intf.url = url; var bareParam = new my_param_class_object(); bareParam.setWhatever(someValue); // ... intf.compliant(successCallback, errorCallback, bareParam); } |
.h3 xs:any Example: Using a Described Type
The following function calls a Document/Literal/Bare method. The bare parameter element is declared as:
Code Block | ||||
---|---|---|---|---|
| ||||
<element name="acceptAny1">
<complexType>
<sequence>
<element name='before' type='string' />
<any minOccurs='1' maxOccurs='1' namespace='##other' />
<element name='after' type='string' />
</sequence>
</complexType>
</element>
|
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 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
an element named alternative1. In the function below, the JavaScript creates an object for the service, and then an object for the acceptAny1 element.
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').
Code Block | ||||
---|---|---|---|---|
| ||||
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);
}
|