With reference to the MessageIdHandler example in your book, I have a question. It is mentioned that the JAX-RPC runtime will invoke the handler if the MessageIdHandler if the getHeaders method contains the header message-id but I find the MessageIdHandler creates the message-id header. So how does it get called ? Could you please clarify. Please let me know if I have understood things wrongly.
Excellent question. For outgoing messages, those that are being sent by client or replies being returned by a sever, all the handlers will have a chance to process the outgoing SOAP message via the Handlers. The getHeaders is not really considered. For incoming messages, those that are being received by a client as response OR initial requests sent to a server, the getHeaders( ) method is important. The handler chain will collect all the headers returned by all of its Handlers and cache them. It will use this cache to determine if the SOAP message needs to processed. If even one header matches, while all others do not, the SOAP message will be processed by the entire handler chain. The point is that the getHeaders is the way in which an individual handler tells the handler chain that its headers should be considered when deciding if a SOAP message should be processed by the entire handler chain - if none of the headers supplied by individual handlers in the chain have a match in the SOAP message, then the handler chain can be bypassed. Whether or not it is bypassed is probably going to be a vendor specific thing. The good thing is that you really don't need to worry about it because each handler is supposed to only process those headers it was designed for. When a handler's processRequest( )/processResponse() method is called, it looks for its header block, if its not there, it just returns true so that the next handler in the chain, or the endpoint, can process the message. In other words, handlers should ignore SOAP messages that don't have their header. I hope that makes sense, Richard
I have another question related the MessageHandler. As mentioned in your book, a JSE can implments ServiceLifecyle interafce to be able to cach a javax.xml.rpc.handler.MessageContext object. However, each of handleXXX() methods for MessageHandler also receives such object. Are these too objects gurranteed the same object(of course, within client's one invocation) or rather it is vender specific? Thanks,
Thanks for reply, just want to point out that my question is about the object received in handler and the object received in the init() method of ServiceLifecyle interface implemented by JSE, if one choose to implement for his JSE. I'd think they should the same object. I'd like to see if J2EE spec will require they are same. But I couldn't find it. Regards