>
> my question is the subject: is it posiible to set/modify the content of
> the SOAP header with the JAX-RPC API or must I use SAAJ?
The answer really is "both" :)
You can access the SOAPHeader of a message through a jaxrpc handler, and
once you have it you use the saaj api's to modify the message.
For instance, in you handler, you can do something like this (try/catch
block excluded for readability):
public boolean handleRequest(MessageContext context) {
SOAPMessageContext smc = (SOAPMessageContext) context;
SOAPMessage message = smc.getMessage();
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
SOAPHeader newHeader = envelope.addHeader();
newHeader.addHeaderElement(....);
// other code
return true;
}
To be safe, you should check to see if the envelope already contains a
header first, but I wanted to show a simple example of doing this. If
you're new to handlers, there should be an example in the tutorial about
it. Basically you write the handler and put it in the config.xml file
and it gets generated along with the other code. Or you can add a
handler at runtime with the API's if you're using a dynamic client.
Here's the skeleton of a very simple handler to get going
(GenericHandler and MessageContext are in the javax.xml.rpc.handler
package):
public class MyHandler extends GenericHandler {
public javax.xml.namespace.QName[] getHeaders() {
return null;
}
public boolean handleRequest(MessageContext context) {
return true;
}
public boolean handleResponse(MessageContext context) {
return true;
}
}
Cheers,
Bobby
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net