Versions Compared

Key

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

...

Code Block
javascript
javascript
// Javascript for {http://apache.org/hello_world_soap_http}Greeter

function apache_org_hello_world_soap_http_Greeter () {
    this.jsutils = new CxfApacheOrgUtil();
    this.synchronous = false;
    this.url = null;
    this.client = null;
    this.response = null;
    this._onsuccess = null;
    this._onerror = null;
}

There

...

are

...

two

...

important

...

properties

...

defined

...

here:

...

url

...

and

...

synchronous

...

.

URL

You are responsible for setting the url property with the URL of the web service. The generated JavaScript does not include any concept of services and ports. You simply put the appropriate URL into the property. Note: CXF's JavaScript clients don't support cross-scripting. If you want to cross-script, you have some choices:

  • 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 CXF JavaScript code generator is designed to facilitate typical, AJAX, asynchronous processing. As described below, the per-operation functions take callbacks as parameters, and call them back when the server responds. If you want to use synchronous communications, you can set the 'synchronous' property to 'true'. That does not change the API, but rather changes the behavior. With this setting, the operation functions do not return until after the server has responded and the callbacks have been called back.

Per-Operation Functions

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 success callback is called back with one parameter: the JavaScript object corresponding to the response.

What is that object? Well, that depends on the schema of the operation. If you are using Document/Literal/Wrapped, it will be a JavaScript object corresponding to the wrapper object for the output part. If you are using Document/Literal/Bare, it will correspond to the output part. If the output part has a simple type, such as String, the response callback will be called with a simple JavaScript object.

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.

When/if the client JavaScript generator is improved to have more comprehensive support for faults, the protocol will change to pass
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 mu