ws-fx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Essington <jas...@GreenRiverComputing.com>
Subject Setting header values
Date Fri, 02 Jul 2004 15:43:03 GMT
I just started looking at the Addressing package, and am trying to 
figure out the best way to set my wsa:From and wsa:ReplyTo headers.

The wsa:To header is set via call.setTargetEndpointAddress() and the 
wsa:Action can be similarly set via the call.setSOAPActionURI() method, 
but when I want to set the other header values I have to do something 
like:

          // add some stuff to the addressing headers
          AddressingHeaders headers = new AddressingHeaders();
          headers.setFrom(new 
EndpointReference("mailto:me@mydomain.com"));
          headers.setReplyTo(new 
EndpointReference("mailto:responses@mydomain.com"));
          call.setProperty(Constants.ENV_ADDRESSING_REQUEST_HEADERS, 
headers);

This is counter intuitive and makes the client terribly dependent upon 
the addressing classes.

wss4j allows you to set call properties to set the values used by it's 
handlers, so could addressing do something similar? Something like:

          call.setProperty(Constants.ADDRESSING_FROM, 
"mailto:me@mydomain.com");
          call.setProperty(Constants.ADDRESSING_REPLYTO, 
"mailto:responses@mydomain.com");

Then the handler could check those properties and set the values 
accordingly something like:

         if (headers.getFrom() == null) {
             String from = 
msgContext.getStrProp(Constants.ADDRESSING_FROM);
             if (from == null) {
                 headers.setFrom(new 
EndpointReference(Constants.NS_URI_ANONYMOUS));
             } else {
                 headers.setFrom(new EndpointReference(from));
             }
         }

         if (msgContext.isPropertyTrue("addressing.sendReplyTo")) {
             if (headers.getReplyTo() == null) {
                 headers.setReplyTo(headers.getFrom());
             }
         } else if (headers.getReplyTo() == null) {
            String replyTo = 
msgContext.getStrProp(Constants.ADDRESSING_REPLYTO);
            if (replyTo == null) {
                headers.setReplyTo(new 
EndpointReference(Constants.NS_URI_ANONYMOUS));
            } else {
                headers.setReplyTo(new EndpointReference(replyTo));
            }
         }

Is this a reasonable way to get header values set on the client side? 
It sure helps decouple the calling service from addressing a bit. 
Meaning if addressing isn't present in the handler chain, then those 
extra properties are just ignored.

-jason


Mime
View raw message