Skip to end of metadata
Go to start of metadata

This is a quick guide to using the generated client-side services.

Getting an instance of the client-side service.

The generated client-side services are nothing more than simple interfaces with an associated implementation class. The implementation classes are found in the "impl" subpackage of the package where the interfaces are found. Each implementation can be instantiated by choosing the appropriate constructor. The default constructor will make all service requests to the default URL of the SOAP endpoint. You can use the other constructor if you want to point service requests to a different URL.

Separating the interfaces from the implementation classes allows for maximum flexibility in obtaining instances of the service. Each service lends itself nicely to dependency injection and AOP interceptors.

For example, suppose a service interface com.mycompany.MyService:

To instantiate the service directly:

To instantiate a service that points to a different URL:

Configuring the underlying HTTP requests

You can configure static HTTP headers directly using the setHttpHeaders method on the implementation class.

You can set the username/password for HTTP basic authentication by using the setHttpAuthCredentials method on the implementation class.

Enunciate uses the Apache Commons HTTPClient API to handle the underlying HTTP requests and responses. Cookies are enabled by default. You can maintain your own http state (for handling cookies, authentication credentials, and proxy information) by setting the HttpState object on the implementation class.

And, for more advanced, low-level handling of requests, you can create your own instance of org.codehaus.enunciate.modules.xfire_client.RequestHandler that will be used to configure the request before the request is sent and the response after the response is received.

  • No labels