-//\r
-// SoapContext.cs: SOAP Context\r
-//\r
-// Author:\r
-// Sebastien Pouliot (spouliot@motus.com)\r
-//\r
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)\r
-//\r
-\r
-using Microsoft.Web.Services.Dime;\r
-using Microsoft.Web.Services.Referral;\r
-using Microsoft.Web.Services.Routing;\r
-using Microsoft.Web.Services.Security;\r
-using Microsoft.Web.Services.Timestamp;\r
-#if !WSE1\r
-using Microsoft.Web.Services.Addressing;\r
-#endif\r
-\r
-using System;\r
-using System.Collections;\r
-\r
-namespace Microsoft.Web.Services {\r
-\r
- public sealed class SoapContext {\r
-\r
- private SoapEnvelope envelope;\r
- private Uri actor;\r
- private Microsoft.Web.Services.Timestamp.Timestamp timestamp;\r
- private Microsoft.Web.Services.Security.Security security;\r
- private Hashtable table;\r
- \r
- #if !WSE1\r
- private AddressingHeaders addressingHeaders;\r
- #endif\r
- \r
- internal SoapContext () \r
- {\r
- timestamp = new Microsoft.Web.Services.Timestamp.Timestamp ();\r
- table = new Hashtable ();\r
- }\r
-\r
- internal SoapContext (SoapEnvelope env) \r
- {\r
- envelope = env;\r
- timestamp = new Microsoft.Web.Services.Timestamp.Timestamp ();\r
- table = new Hashtable ();\r
- }\r
-\r
- public Uri Actor { \r
- get { return actor; }\r
- }\r
-\r
-\r
- #if !WSE1\r
- public Action Action {\r
- get { return addressingHeaders.Action; }\r
- set { addressingHeaders.Action = value; }\r
- }\r
-\r
- public ReplyTo ReplyTo {\r
- get { return addressingHeaders.ReplyTo; }\r
- set { addressingHeaders.ReplyTo = value; }\r
- }\r
-\r
- public To To {\r
- get { return addressingHeaders.To; }\r
- }\r
- #endif\r
-\r
- public DimeAttachmentCollection Attachments { \r
- get { return null; }\r
- }\r
-\r
- public string ContentType { \r
- get { return null; }\r
- }\r
-\r
- public SoapEnvelope Envelope { \r
- get { return envelope; }\r
- }\r
-\r
- public SecurityCollection ExtendedSecurity {\r
- get { return null; }\r
- }\r
-\r
- public object this [string key] { \r
- get { return table [key]; }\r
- set { \r
- if (key == null)\r
- throw new ArgumentNullException ("key");\r
- table [key] = value;\r
- } \r
- }\r
-\r
- public Path Path { \r
- get { return null; }\r
- set {;} \r
- }\r
-\r
- public ReferralCollection Referrals { \r
- get { return null; }\r
- }\r
-\r
- public Microsoft.Web.Services.Security.Security Security { \r
- get { \r
- if ((security == null) && (actor != null))\r
- security = new Microsoft.Web.Services.Security.Security (actor.ToString ());\r
- return security; \r
- }\r
- }\r
-\r
- public Microsoft.Web.Services.Timestamp.Timestamp Timestamp { \r
- get { return timestamp; }\r
- }\r
-\r
- internal bool IsReserved (string key) \r
- {\r
- switch (key) {\r
- case "Actor":\r
- case "Attachments":\r
- case "ContentType":\r
- case "Envelope":\r
- case "ExtendedSecurity":\r
- case "IsInbound":\r
- case "IsIntermediary":\r
- case "Referrals":\r
- case "Path":\r
- case "Security":\r
- case "Timestamp":\r
- case "WebRequest":\r
- case "WebResponse":\r
- return true;\r
- default:\r
- return false;\r
- }\r
- }\r
-\r
- public void Add (string key, object value) \r
- {\r
- if (key == null)\r
- throw new ArgumentNullException ("key");\r
- if (IsReserved (key))\r
- throw new ArgumentException ("reserved key");\r
- table.Add (key, value);\r
- }\r
-\r
- public void Clear () \r
- {\r
- foreach (DictionaryEntry entry in table) {\r
- string key = (string) entry.Key;\r
- // remove all except reserved names\r
- if (!IsReserved (key))\r
- table.Remove (key);\r
- }\r
- }\r
-\r
- public bool Contains (string key) \r
- {\r
- if (key == null)\r
- throw new ArgumentNullException ("key");\r
- return table.Contains (key);\r
- }\r
-\r
- public void CopyTo (SoapContext context) \r
- {\r
- if (context == null)\r
- throw new ArgumentNullException ("context");\r
- }\r
-\r
- public IDictionaryEnumerator GetEnumerator () \r
- {\r
- return table.GetEnumerator ();\r
- }\r
-\r
- public void Remove (string key) \r
- {\r
- if (key == null)\r
- throw new ArgumentNullException ("key");\r
- if (IsReserved (key))\r
- throw new ArgumentException ("reserved key");\r
- table.Remove (key);\r
- }\r
- }\r
-}\r
+//
+// SoapContext.cs: SOAP Context
+//
+// Author:
+// Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using Microsoft.Web.Services.Dime;
+using Microsoft.Web.Services.Referral;
+using Microsoft.Web.Services.Routing;
+using Microsoft.Web.Services.Security;
+using Microsoft.Web.Services.Timestamp;
+#if !WSE1
+using Microsoft.Web.Services.Addressing;
+using Microsoft.Web.Services.Messaging;
+#endif
+
+using System;
+using System.Collections;
+
+namespace Microsoft.Web.Services {
+
+ public sealed class SoapContext {
+
+ private SoapEnvelope envelope;
+#if WSE1
+ private Uri actor;
+ private Microsoft.Web.Services.Timestamp.Timestamp timestamp;
+#else
+ private Uri actor = new Uri ("http://" + System.Net.Dns.GetHostName ());
+ private Microsoft.Web.Services.Timestamp.Timestamp timestamp = new Microsoft.Web.Services.Timestamp.Timestamp ();
+#endif
+ private Microsoft.Web.Services.Security.Security security;
+ private Hashtable table;
+ private DimeAttachmentCollection attachments;
+ private string contentType;
+ private SecurityCollection extendedSecurity;
+ private ReferralCollection referrals;
+#if !WSE1
+ private AddressingHeaders addressingHeaders;
+ private SoapChannel _channel;
+ private bool _processed = false;
+ private bool _isInbound = false;
+#endif
+ internal SoapContext () : this (null)
+ {
+ }
+
+ internal SoapContext (SoapEnvelope env)
+ {
+ timestamp = new Microsoft.Web.Services.Timestamp.Timestamp ();
+#if WSE1
+ table = new Hashtable ();
+
+ envelope = env;
+#else //WSE2
+ addressingHeaders = new AddressingHeaders (env);
+
+ envelope = env;
+#endif
+ }
+#if !WSE1
+ public Action Action {
+ get { return addressingHeaders.Action; }
+ set { addressingHeaders.Action = value; }
+ }
+
+ public ReplyTo ReplyTo {
+ get { return addressingHeaders.ReplyTo; }
+ set { addressingHeaders.ReplyTo = value; }
+ }
+
+ public To To {
+ get { return addressingHeaders.To; }
+ }
+
+ public AddressingHeaders Addressing {
+ get { return addressingHeaders; }
+ set { addressingHeaders = value; }
+ }
+
+ public FaultTo FaultTo {
+ get { return addressingHeaders.FaultTo; }
+ set { addressingHeaders.FaultTo = value; }
+ }
+
+ public From From {
+ get { return addressingHeaders.From; }
+ set { addressingHeaders.From = value; }
+ }
+
+ public MessageID MessageID {
+ get { return addressingHeaders.MessageID; }
+ set { addressingHeaders.MessageID = value; }
+ }
+
+ public Recipient Recipient {
+ get { return addressingHeaders.Recipient; }
+ set { addressingHeaders.Recipient = value; }
+ }
+
+ public RelatesTo RelatesTo {
+ get { return addressingHeaders.RelatesTo; }
+ set { addressingHeaders.RelatesTo = value; }
+ }
+
+ public SoapChannel Channel {
+ get { return _channel; }
+ set { _channel = value; }
+ }
+
+ public bool Processed {
+ get { return _processed; }
+ }
+
+ public void SetProcessed (bool to) {
+ _processed = to;
+ }
+
+ public void SetTo (Uri uri) {
+ addressingHeaders.To = uri;
+ }
+
+ public void SetTo (To to) {
+ addressingHeaders.To = to;
+ }
+
+ public void SetActor (Uri act)
+ {
+ actor = act;
+ }
+
+ public void SetIsInbound (bool to)
+ {
+ _isInbound = to;
+ }
+#endif
+ public Uri Actor {
+ get { return actor; }
+ }
+
+ public DimeAttachmentCollection Attachments {
+ get {
+ if (attachments == null)
+ attachments = new DimeAttachmentCollection ();
+ return attachments;
+ }
+ }
+
+ public string ContentType {
+ get { return contentType; }
+ }
+
+ public SoapEnvelope Envelope {
+ get { return envelope; }
+ }
+
+ public SecurityCollection ExtendedSecurity {
+ get {
+ if (extendedSecurity == null)
+ extendedSecurity = new SecurityCollection ();
+ return extendedSecurity;
+ }
+ }
+
+ public object this [string key] {
+ get { return table [key]; }
+ set {
+ if (key == null)
+ throw new ArgumentNullException ("key");
+ table [key] = value;
+ }
+ }
+
+ public Path Path {
+ get { return null; }
+ set {;}
+ }
+
+ public ReferralCollection Referrals {
+ get { return referrals; }
+ }
+
+ public Microsoft.Web.Services.Security.Security Security {
+ get {
+ if (security == null) {
+ if (actor != null)
+ security = new Microsoft.Web.Services.Security.Security (actor.ToString ());
+ else
+ security = new Microsoft.Web.Services.Security.Security ();
+ }
+ return security;
+ }
+ }
+
+ public Microsoft.Web.Services.Timestamp.Timestamp Timestamp {
+ get { return timestamp; }
+ }
+
+ internal bool IsReserved (string key)
+ {
+ switch (key) {
+ case "Actor":
+ case "Attachments":
+ case "ContentType":
+ case "Envelope":
+ case "ExtendedSecurity":
+ case "IsInbound":
+ case "IsIntermediary":
+ case "Referrals":
+ case "Path":
+ case "Security":
+ case "Timestamp":
+ case "WebRequest":
+ case "WebResponse":
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public void Add (string key, object value)
+ {
+ if (key == null)
+ throw new ArgumentNullException ("key");
+ if (IsReserved (key))
+ throw new ArgumentException ("reserved key");
+ table.Add (key, value);
+ }
+
+ public void Clear ()
+ {
+ foreach (DictionaryEntry entry in table) {
+ string key = (string) entry.Key;
+ // remove all except reserved names
+ if (!IsReserved (key))
+ table.Remove (key);
+ }
+ }
+
+ public bool Contains (string key)
+ {
+ if (key == null)
+ throw new ArgumentNullException ("key");
+ return table.Contains (key);
+ }
+
+ public void CopyTo (SoapContext context)
+ {
+ if (context == null)
+ throw new ArgumentNullException ("context");
+ context.actor = this.actor;
+ foreach (DimeAttachment da in Attachments) {
+ context.Attachments.Add (da);
+ }
+ context.contentType = contentType;
+ context.envelope = envelope;
+ context.extendedSecurity = ExtendedSecurity;
+ context.Path = Path;
+ context.referrals = Referrals;
+ context.security = security;
+ context.timestamp = timestamp;
+ foreach (DictionaryEntry de in table) {
+ context.table.Add (de.Key, de.Value);
+ }
+ }
+
+ public IDictionaryEnumerator GetEnumerator ()
+ {
+ return table.GetEnumerator ();
+ }
+
+ public void Remove (string key)
+ {
+ if (key == null)
+ throw new ArgumentNullException ("key");
+ if (IsReserved (key))
+ throw new ArgumentException ("reserved key");
+ table.Remove (key);
+ }
+ }
+}