2 // SoapContext.cs: SOAP Context
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
10 using Microsoft.Web.Services.Dime;
11 using Microsoft.Web.Services.Referral;
12 using Microsoft.Web.Services.Routing;
13 using Microsoft.Web.Services.Security;
14 using Microsoft.Web.Services.Timestamp;
16 using Microsoft.Web.Services.Addressing;
20 using System.Collections;
22 namespace Microsoft.Web.Services {
24 public sealed class SoapContext {
26 private SoapEnvelope envelope;
28 private Microsoft.Web.Services.Timestamp.Timestamp timestamp;
29 private Microsoft.Web.Services.Security.Security security;
30 private Hashtable table;
31 private DimeAttachmentCollection attachments;
32 private string contentType;
33 private SecurityCollection extendedSecurity;
34 private ReferralCollection referrals;
36 private AddressingHeaders addressingHeaders;
38 internal SoapContext ()
40 timestamp = new Microsoft.Web.Services.Timestamp.Timestamp ();
41 table = new Hashtable ();
44 internal SoapContext (SoapEnvelope env)
47 timestamp = new Microsoft.Web.Services.Timestamp.Timestamp ();
48 table = new Hashtable ();
51 public Action Action {
52 get { return addressingHeaders.Action; }
53 set { addressingHeaders.Action = value; }
56 public ReplyTo ReplyTo {
57 get { return addressingHeaders.ReplyTo; }
58 set { addressingHeaders.ReplyTo = value; }
62 get { return addressingHeaders.To; }
69 public DimeAttachmentCollection Attachments {
71 if (attachments == null)
72 attachments = new DimeAttachmentCollection ();
77 public string ContentType {
78 get { return contentType; }
81 public SoapEnvelope Envelope {
82 get { return envelope; }
85 public SecurityCollection ExtendedSecurity {
86 get { return extendedSecurity; }
89 public object this [string key] {
90 get { return table [key]; }
93 throw new ArgumentNullException ("key");
103 public ReferralCollection Referrals {
104 get { return referrals; }
107 public Microsoft.Web.Services.Security.Security Security {
109 if (security == null) {
111 security = new Microsoft.Web.Services.Security.Security (actor.ToString ());
113 security = new Microsoft.Web.Services.Security.Security ();
119 public Microsoft.Web.Services.Timestamp.Timestamp Timestamp {
120 get { return timestamp; }
123 internal bool IsReserved (string key)
130 case "ExtendedSecurity":
132 case "IsIntermediary":
145 public void Add (string key, object value)
148 throw new ArgumentNullException ("key");
149 if (IsReserved (key))
150 throw new ArgumentException ("reserved key");
151 table.Add (key, value);
156 foreach (DictionaryEntry entry in table) {
157 string key = (string) entry.Key;
158 // remove all except reserved names
159 if (!IsReserved (key))
164 public bool Contains (string key)
167 throw new ArgumentNullException ("key");
168 return table.Contains (key);
171 public void CopyTo (SoapContext context)
174 throw new ArgumentNullException ("context");
175 context.actor = this.actor;
176 foreach (DimeAttachment da in Attachments) {
177 context.Attachments.Add (da);
179 context.contentType = contentType;
180 context.envelope = envelope;
181 context.extendedSecurity = ExtendedSecurity;
183 context.referrals = Referrals;
184 context.security = security;
185 context.timestamp = timestamp;
186 foreach (DictionaryEntry de in table) {
187 context.table.Add (de.Key, de.Value);
191 public IDictionaryEnumerator GetEnumerator ()
193 return table.GetEnumerator ();
196 public void Remove (string key)
199 throw new ArgumentNullException ("key");
200 if (IsReserved (key))
201 throw new ArgumentException ("reserved key");