Versions Compared

Key

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

...

For example:

Code Block
java
java

@WebService
@WSDLDocumentationCollection(
    {
        @WSDLDocumentation("My portType documentation"),
        @WSDLDocumentation(value = "My top level documentation",
                           placement = WSDLDocumentation.Placement.TOP),
        @WSDLDocumentation(value = "My binding doc",
                           placement = WSDLDocumentation.Placement.BINDING)
    }
)
public interface MyService {

    @WSDLDocumentation("The docs for echoString")
    String echoString(String s);

}

...

Turns on SchemaValidation for messages. By default, for performance reasons, CXF does not validate message against the schema. By turning on validation, problems with messages not matching the schema are easier to determine.   These annotations can be applied globally to the SEI, but also can be applied at method level in both the SEI and Implementation.

 

INApply schema validation to INcoming messages on client and server
REQUEST(Since 2.7.14, 3.0.3, 3.1) Apply schema validation to Request messages.  This annotation will cause validation to be applied to OUTgoing Client messages, and INcoming Server messages.
OUTApply schema validation to OUTgoing messages on Client and Server
RESPONSE(Since 2.7.14, 3.0.3, 3.1) Apply schema validation to Response messages.  This annotation will cause validation to be applied to INcoming Client messages, and OUTgoing Server messages.
BOTHApply schema validation to both INcoming and OUTgoing messages on Client and Server
NONEAll schema validation is disabled.
Code Block
languagejava
@WebService
@SchemaValidation(type = SchemaValidationType.BOTH)
public interface MyService {
    Foo validateBoth(Bar data);

    @SchemaValidation(type = SchemaValidationType.NONE)
    Foo validateNone(Bar data);

    @SchemaValidation(type = SchemaValidationType.IN)
    Foo validateIn(Bar data);

    @SchemaValidation(type = SchemaValidationType.OUT)
    Foo validateOut(Bar data);

    @SchemaValidation(type = SchemaValidationType.REQUEST)
    Foo validateRequest(Bar data);

    @SchemaValidation(type = SchemaValidationType.RESPONSE)
    Foo validateResponse(Bar data);
}

 

Anchor
DataBinding
DataBinding

...

Sets the DataBinding class that is associated with the service. By default, CXF assumes you are using the JAXB data binding. However, CXF supports different databindings such as XMLBeans, Aegis, SDO, and possibly more. This annotation can be used in place of configuration to select the databinding class.

Code Block
java
java

@DataBinding(org.apache.cxf.sdo.SDODataBinding.class)
public interface MyService {
    public commonj.sdo.DataObject echoStruct(
        commonj.sdo.DataObject struct
    );
}

...

limit

Sets the size limit after which the message is truncated in the logs. Default is 64K

inLocation

Sets the location to log incoming messages. Can be <stderr>, <stdout>, <logger>, or a file: URL. Default is <logger>

outLocation

Sets the location to log outgoing messages. Can be <stderr>, <stdout>, <logger>, or a file: URL. Default is <logger>

Code Block

@Logging(limit=16000, inLocation="<stdout>")
public interface MyService {

    String echoString(String s);

}

...

threshold

the threshold under which messages are not gzipped

force

force GZIP compression instead of negotiating via the Accept-Encoding header

GZIP is a negotiated enhancement. An initial request from a client will not be gzipped, but an Accept header will be added and if the server supports it, the response will be gzipped and any subsequent requests will be.

...

Adds a property to an endpoint. Many things such as WS-Security related things and such can be configured via endpoint properties. Traditionally, these would be set via the <jaxws:properties> element on the <jaxws:endpoint> element in the spring config, but these annotations allow these properties to be configured into the code.

Code Block
java
java

@WebService
@EndpointProperties(
    {
       @EndpointProperty(key = "my.property", value="some value"),
       @EndpointProperty(key = "my.other.property", value="some other value"),
    })
public interface MyService {
    String echoString(String s);
}

...

Note

When using a custom Spring configuration, you need to import META-INF/cxf/cxf-extension-policy.xml

Code Block
java
java



@Policies({
    @Policy(uri = "annotationpolicies/TestInterfacePolicy.xml"),
    @Policy(uri = "annotationpolicies/TestImplPolicy.xml",
            placement = Policy.Placement.SERVICE_PORT),
    @Policy(uri = "annotationpolicies/TestPortTypePolicy.xml", 
            placement = Policy.Placement.PORT_TYPE)
}
)
@WebService
public static interface TestInterface {
    @Policies({
        @Policy(uri = "annotationpolicies/TestOperationPolicy.xml"),
        @Policy(uri = "annotationpolicies/TestOperationInputPolicy.xml", 
                placement = Policy.Placement.BINDING_OPERATION_INPUT),
        @Policy(uri = "annotationpolicies/TestOperationOutputPolicy.xml", 
                placement = Policy.Placement.BINDING_OPERATION_OUTPUT),
        @Policy(uri = "annotationpolicies/TestOperationPTPolicy.xml", 
                placement = Policy.Placement.PORT_TYPE_OPERATION),
        @Policy(uri = "annotationpolicies/TestOperationPTInputPolicy.xml", 
                placement = Policy.Placement.PORT_TYPE_OPERATION_INPUT),
        @Policy(uri = "annotationpolicies/TestOperationPTOutputPolicy.xml", 
                placement = Policy.Placement.PORT_TYPE_OPERATION_OUTPUT)
    }
    )
    int echoInt(int i);
}

...

Used on the JAX-WS service implementation object to mark a method as preferring the 'async' version of the method instead of the synchronous version. With JAX-WS, services default to the synchronous methods that require the returning value to be returned from the method. By marking a method with the @UseAsyncMethod annotation, if the transport supports it, CXF will call the async version that takes an AsynHandler AsyncHandler object and the service can call that handler when the response is ready. If the transport does not support the CXF continuations, the synchronous method will be called as normal.

Code Block
java
java


    @UseAsyncMethod
    public String greetMeSometime(String me) {
        LOG.info("Executing operation greetMeSometime synchronously");
        System.out.println("Executing operation greetMeSometime synchronously\n");
        return "How are you " + me;
    }

    public Future<?>  greetMeSometimeAsync(final String me, 
                                           final AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
        LOG.info("Executing operation greetMeSometimeAsync asynchronously");
        System.out.println("Executing operation greetMeSometimeAsync asynchronously\n");
        final ServerAsyncResponse<GreetMeSometimeResponse> r 
            = new ServerAsyncResponse<GreetMeSometimeResponse>();
        new Thread() {
            public void run() {
                GreetMeSometimeResponse resp = new GreetMeSometimeResponse();
                resp.setResponseType("How are you " + me);
                r.set(resp);
                System.out.println("Responding on background thread\n");
                asyncHandler.handleResponse(r);
            }
        } .start();
        
        return r; 
    }