public final class XmlHttpRequestProcessor extends java.lang.Object implements RequestProcessor
RequestProcessor
interface that
turns Request
objects into XML, adds the necessary security details,
sends them over HTTP to the Degree Days.net API servers, and parses the XML
responses into Response
object models.
To create an instance of this class, you'll need to use the XmlHttpRequestProcessor.Builder
class. Using a Builder
you can heavily customize the way in
which the created XmlHttpRequestProcessor
works. For example, a
default XmlHttpRequestProcessor
uses java.net
classes to manage connections to the API servers, but you might want to swap
in HttpClient-based functionality if the rest of your application uses
HttpClient.
For more on the customization options, see the docs for the XmlHttpRequestProcessor.Builder
.
This class is designed to be safe for use in a multi-threaded environment. However, if you create a customized instance of this class, then the thread-safety of its operation will depend on the thread-safety of any custom processing components that you introduce.
Modifier and Type | Class and Description |
---|---|
static class |
XmlHttpRequestProcessor.Builder
Builds
XmlHttpRequestProcessor objects: create and configure a
Builder object, then call XmlHttpRequestProcessor.Builder.build() to create an
XmlHttpRequestProcessor object. |
Modifier and Type | Method and Description |
---|---|
Response |
process(Request request)
Processes the
Request object and returns a
Response object which is either a
FailureResponse or a
Response that's type is the counterpart to
that of the Request object passed in. |
public Response process(Request request) throws TransportException
RequestProcessor
Request
object and returns a
Response
object which is either a
FailureResponse
or a
Response
that's type is the counterpart to
that of the Request
object passed in.
For example, successful processing of a
LocationDataRequest
will result in a
LocationDataResponse
.
process
in interface RequestProcessor
request
- the Request
to be processed. Cannot be
null
.Response
object which is either a
FailureResponse
or a
Response
that's type is is the
counterpart to that of the Request
passed in.TransportException
- if there is a network- or stream-related
error.
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.