Codehaus XFire
DocumentationQuicklinksDevelopers
Sponsors |
The MessageContextThe MessageContext class stays with an XFire invocation from start to finish. It is useful for:
Accessing the MessageContext from your OperationIn some cases you want to be able to access XFire's MessageContext. The Invokers that come with XFire allow you to add a MessageContext variable to your operation like so: public String echo(String echo, MessageContext context) { // do something with the context... return echo; } XFire will just inject the MessageContext for you. With no ThreadLocal magic at all! Accessing Messages and their XMLThe MessageContext has some accessors that easy to access messages associated with the invocation.
Getting at the XMLXFire is based on a completely streaming model. So you have two options if you want to get at the XML. The first is to use the Message Binding. This way XFire won't read the stream into Objects for you, and you can access the XMLStreamReader yourself. The second way is to switch to "DOM Mode" by using the DOMInHandler and DOMOutHandler. These handlers can be registered with the service Service service = ... // retreive your service from the ServiceRegistry service.addInHandler(new DOMInHandler()) service.addOutHandler(new DOMInHandler()) Then you can access the org.w3c.dom.Document for the message: public void invoke(MessageContext context) {
Document inputDoc = context.getInMessage().getProperty(DOMInHandler.DOM_MESSAGE):
Document outputDoc = context.getOutMessage().getProperty(DOMOutHandler.DOM_MESSAGE):
}
|