View Javadoc

    1   package org.codehaus.xfire.exchange;
    2
    3   import java.util.HashMap;
    4   import java.util.Map;
    5
    6   import org.codehaus.xfire.attachments.Attachments;
    7   import org.codehaus.xfire.soap.Soap11;
    8   import org.codehaus.xfire.soap.SoapVersion;
    9   import org.codehaus.xfire.soap.SoapVersionFactory;
    10  import org.codehaus.xfire.transport.Channel;
    11  import org.codehaus.yom.Element;
    12
    13  public abstract class AbstractMessage
    14  {
    15      public static final String ANONYMOUS_URI = "urn:codehaus:xfire:anonymous";
    16
    17      private Element header;
    18      private String uri;
    19      private String encoding = "UTF-8";
    20      private String action;
    21      private Object body;
    22      private Attachments attachments;
    23      private SoapVersion soapVersion = Soap11.getInstance();
    24      private Channel channel;
    25      private Map properties = new HashMap();
    26
    27      public Object getBody()
    28      {
    29          return body;
    30      }
    31
    32      public void setBody(Object body)
    33      {
    34          this.body = body;
    35      }
    36
    37      public Channel getChannel()
    38      {
    39          return channel;
    40      }
    41
    42      public void setChannel(Channel channel)
    43      {
    44          this.channel = channel;
    45      }
    46
    47      public SoapVersion getSoapVersion()
    48      {
    49          return soapVersion;
    50      }
    51
    52      public void setSoapVersion(String soapVersion)
    53      {
    54          this.soapVersion = SoapVersionFactory.getInstance().getSoapVersion(soapVersion);
    55      }
    56
    57      public void setSoapVersion(SoapVersion soapVersion)
    58      {
    59          this.soapVersion = soapVersion;
    60      }
    61
    62      public String getEncoding()
    63      {
    64          return encoding;
    65      }
    66
    67      public void setEncoding(String encoding)
    68      {
    69          this.encoding = encoding;
    70      }
    71
    72      public String getAction()
    73      {
    74          return action;
    75      }
    76
    77      public void setAction(String action)
    78      {
    79          this.action = action;
    80      }
    81
    82      public boolean hasHeader()
    83      {
    84          return header != null;
    85      }
    86
    87      public Element getHeader()
    88      {
    89          if (header == null)
    90          {
    91              header = new Element(getSoapVersion().getPrefix() + ":Header", getSoapVersion().getNamespace());
    92          }
    93          return header;
    94      }
    95
    96      public void setHeader(Element header)
    97      {
    98          this.header = header;
    99      }
    100
    101     public String getUri()
    102     {
    103         return uri;
    104     }
    105
    106     public void setUri(String uri)
    107     {
    108         this.uri = uri;
    109     }
    110
    111     public Attachments getAttachments()
    112     {
    113         return attachments;
    114     }
    115
    116     public void setAttachments(Attachments attachments)
    117     {
    118         this.attachments = attachments;
    119     }
    120
    121     public Object getProperty(Object key)
    122     {
    123         return properties.get(key);
    124     }
    125
    126     public void setProperty(Object key, Object value)
    127     {
    128         properties.put(key, value);
    129     }
    130
    131     public String toString()
    132     {
    133         return super.toString() + "[uri=\"" + getUri() + "\"]";
    134     }
    135 }