Author: atsushi
Date: 2007-03-07 03:35:59 -0500 (Wed, 07 Mar 2007)
New Revision: 73871
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
trunk/olive/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs
Log:
2007-03-07 Atsushi Enomoto <[EMAIL PROTECTED]>
* ChannelDispatcher.cs, DispatchRuntime.cs, EndpointDispatcher.cs :
moved most of request/input processing to EndpointDispatcher.cs.
Also, ChannelDispatcher now contains code for behavior
initialization.
* ServiceHostBase.cs :
moved code for applying behavior to ChannelDispatcher.cs.
* ServiceMetadataExtension.cs :
DispatchRuntime.InternalEndpointDispatcher was eliminated.
Modified: trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
2007-03-07 05:31:39 UTC (rev 73870)
+++ trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
2007-03-07 08:35:59 UTC (rev 73871)
@@ -1,5 +1,10 @@
2007-03-07 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * ServiceHostBase.cs :
+ moved code for applying behavior to ChannelDispatcher.cs.
+
+2007-03-07 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* ClientBase.cs : added DisplayInitializationUI() stub.
* ServiceHostBase.cs : raise an error when no channel could be built.
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs
2007-03-07 08:35:59 UTC (rev 73871)
@@ -320,74 +320,14 @@
cd.MessageVersion = se.Binding.MessageVersion;
if (cd.MessageVersion == null)
cd.MessageVersion =
MessageVersion.Default;
- // FIXME: there might be decent way to supply
channel dispatcher to endpoint dispatcher
cd.Attach (this);
-
- // Apply contract/operation behaviors.
- //EndpointDispatcher d = new EndpointDispatcher
(se.Address,
- // se.Contract.Name,
se.Contract.Namespace);
- EndpointDispatcher d =
cd.InternalEndpointDispatcher;
-
- foreach (IEndpointBehavior b in se.Behaviors)
- b.ApplyDispatchBehavior (se, d);
-
- DispatchRuntime db = d.DispatchRuntime;
- foreach (IContractBehavior b in
se.Contract.Behaviors)
- b.ApplyDispatchBehavior (se.Contract,
se, db);
- foreach (OperationDescription od in
se.Contract.Operations) {
- if (!db.Operations.Contains (od.Name))
- PopulateDispatchOperation (db,
od);
- foreach (IOperationBehavior ob in
od.Behaviors)
- ob.ApplyDispatchBehavior (od,
d.DispatchRuntime.Operations [od.Name]);
- }
-
cd.Open ();
}
- // FIXME: Apply service behaviors
foreach (IServiceBehavior b in description.Behaviors)
b.ApplyDispatchBehavior (description, this);
}
- void PopulateDispatchOperation (DispatchRuntime db,
OperationDescription od)
- {
- string reqA = null, resA = null;
- foreach (MessageDescription m in od.Messages) {
- if (m.Direction == MessageDirection.Input)
- reqA = m.Action;
- else
- resA = m.Action;
- }
- DispatchOperation o =
- od.IsOneWay ?
- new DispatchOperation (db, od.Name, reqA) :
- new DispatchOperation (db, od.Name, reqA, resA);
- bool has_void_reply = false;
- foreach (MessageDescription md in od.Messages) {
- if (md.Direction == MessageDirection.Input &&
- md.Body.Parts.Count == 1 &&
- md.Body.Parts [0].Type == typeof (Message))
- o.DeserializeRequest = false;
- if (md.Direction == MessageDirection.Output &&
- md.Body.ReturnValue != null) {
- if (md.Body.ReturnValue.Type == typeof
(Message))
- o.SerializeReply = false;
- else if (md.Body.ReturnValue.Type ==
typeof (void))
- has_void_reply = true;
- }
- }
-
- if (o.Action == "*" && o.ReplyAction == "*") {
- //Signature : Message (Message)
- // : void (Message)
- //FIXME: void (IChannel)
- if (!o.DeserializeRequest && (!o.SerializeReply
|| has_void_reply))
- db.UnhandledDispatchOperation = o;
- }
-
- db.Operations.Add (o);
- }
-
IChannelListener BuildListener (ServiceEndpoint se,
BindingParameterCollection pl)
{
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
2007-03-07 08:35:59 UTC (rev 73871)
@@ -1,3 +1,8 @@
+2007-03-07 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * ServiceMetadataExtension.cs :
+ DispatchRuntime.InternalEndpointDispatcher was eliminated.
+
2007-03-05 Atsushi Enomoto <[EMAIL PROTECTED]>
* WSTrustSTSContract.cs, WSTrustMessageConverters.cs :
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs
2007-03-07 08:35:59 UTC (rev 73871)
@@ -93,7 +93,7 @@
} else if (metadata_beh.HttpGetEnabled
&&
ed.ContractName ==
"HttpGetWsdl" &&
ed.ContractNamespace ==
"http://tempuri.org/") {
-
cd.InternalEndpointDispatcher.DispatchRuntime.InstanceContextProvider =
+
ed.DispatchRuntime.InstanceContextProvider =
new
HttpGetInstanceContextProvider (owner, new HttpGetWsdl (this,
ed.EndpointAddress.Uri));
}
}
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
2007-03-07 08:35:59 UTC (rev 73871)
@@ -1,5 +1,12 @@
2007-03-07 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * ChannelDispatcher.cs, DispatchRuntime.cs, EndpointDispatcher.cs :
+ moved most of request/input processing to EndpointDispatcher.cs.
+ Also, ChannelDispatcher now contains code for behavior
+ initialization.
+
+2007-03-07 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* ChannelDispatcher.cs : some cosmetic refactoring on error handling
with comments.
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
2007-03-07 08:35:59 UTC (rev 73871)
@@ -179,18 +179,66 @@
protected internal override void Attach (ServiceHostBase host)
{
this.host = host;
- ServiceEndpoint ep = FindEndpoint ();
- // FIXME: raise an error in case endpoing was not found.
+ ServiceEndpoint se = FindEndpoint ();
+ // FIXME: raise an error in case endpoint was not found.
endpoint_dispatcher = new EndpointDispatcher (
- ep.Address, ep.Contract.Name,
ep.Contract.Namespace);
+ se.Address, se.Contract.Name,
se.Contract.Namespace);
endpoint_dispatcher.ChannelDispatcher = this;
host.ChannelDispatchers.Add (this);
+
+ foreach (IEndpointBehavior b in se.Behaviors)
+ b.ApplyDispatchBehavior (se,
endpoint_dispatcher);
+
+ // apply behaviors
+ DispatchRuntime db =
endpoint_dispatcher.DispatchRuntime;
+ foreach (IContractBehavior b in se.Contract.Behaviors)
+ b.ApplyDispatchBehavior (se.Contract, se, db);
+ foreach (OperationDescription od in
se.Contract.Operations) {
+ if (!db.Operations.Contains (od.Name))
+ PopulateDispatchOperation (db, od);
+ foreach (IOperationBehavior ob in od.Behaviors)
+ ob.ApplyDispatchBehavior (od,
db.Operations [od.Name]);
+ }
}
- // FIXME: it could be extraneous
- internal EndpointDispatcher InternalEndpointDispatcher {
- get { return endpoint_dispatcher; }
+ void PopulateDispatchOperation (DispatchRuntime db,
OperationDescription od)
+ {
+ string reqA = null, resA = null;
+ foreach (MessageDescription m in od.Messages) {
+ if (m.Direction == MessageDirection.Input)
+ reqA = m.Action;
+ else
+ resA = m.Action;
+ }
+ DispatchOperation o =
+ od.IsOneWay ?
+ new DispatchOperation (db, od.Name, reqA) :
+ new DispatchOperation (db, od.Name, reqA, resA);
+ bool has_void_reply = false;
+ foreach (MessageDescription md in od.Messages) {
+ if (md.Direction == MessageDirection.Input &&
+ md.Body.Parts.Count == 1 &&
+ md.Body.Parts [0].Type == typeof (Message))
+ o.DeserializeRequest = false;
+ if (md.Direction == MessageDirection.Output &&
+ md.Body.ReturnValue != null) {
+ if (md.Body.ReturnValue.Type == typeof
(Message))
+ o.SerializeReply = false;
+ else if (md.Body.ReturnValue.Type ==
typeof (void))
+ has_void_reply = true;
+ }
+ }
+
+ if (o.Action == "*" && o.ReplyAction == "*") {
+ //Signature : Message (Message)
+ // : void (Message)
+ //FIXME: void (IChannel)
+ if (!o.DeserializeRequest && (!o.SerializeReply
|| has_void_reply))
+ db.UnhandledDispatchOperation = o;
+ }
+
+ db.Operations.Add (o);
}
public override void CloseInput ()
@@ -372,107 +420,21 @@
if (reply != null) {
while (loop) {
if (reply.WaitForRequest
(owner.timeouts.ReceiveTimeout))
- ProcessRequest ();
+
owner.endpoint_dispatcher.ProcessRequest (reply);
}
} else if (input != null) {
while (loop) {
if (input.WaitForMessage
(owner.timeouts.ReceiveTimeout))
- ProcessInput ();
+
owner.endpoint_dispatcher.ProcessInput (input);
}
}
}
- void ProcessRequest ()
- {
- try {
- DoProcessRequest ();
- } catch (Exception ex) {
-Console.WriteLine (ex);
- // FIXME: will we need to do something
(like error logging) here.
- }
- }
-
- void DoProcessRequest ()
- {
- DispatchRuntime rt =
owner.endpoint_dispatcher.DispatchRuntime;
-
- IServiceChannel cch = new ServiceRuntimeChannel
(owner.FindEndpoint (), reply);
- // FIXME: some kind of extra consideration to
- // create transport-level RequestContext is
- // needed, to handle errors on wrapping
- // RequestContext layers (such as
- // SecurityRequestContext). Currently there
- // is no way to catch those errors and return
- // it as SOAP Fault...
- RequestContext rc = reply.ReceiveRequest
(owner.timeouts.ReceiveTimeout);
- if (rc == null)
- // FIXME: probably some kind of
reporting is required.
- return;
- if (IsMessageFilteredOut (rc.RequestMessage)) {
- rc.Reply (CreateDestinationUnreachable
(rc.RequestMessage));
- // FIXME: probably some kind of
reporting is required.
- return;
- }
- using (OperationContextScope scope = new
OperationContextScope (cch)) {
-
OperationContext.Current.EndpointDispatcher = owner.endpoint_dispatcher;
- OperationContext.Current.RequestContext
= rc;
- rt.ProcessRequest (rc,
owner.timeouts.SendTimeout);
- }
- }
-
- void ProcessInput ()
- {
- try {
- DoProcessInput ();
- } catch (Exception ex) {
-Console.WriteLine (ex);
- // FIXME: will we need to do something (like
error logging) here.
- }
- }
-
- void DoProcessInput ()
- {
- DispatchRuntime rt =
owner.endpoint_dispatcher.DispatchRuntime;
-
- IServiceChannel cch = new ServiceRuntimeChannel
(owner.FindEndpoint (), input);
- Message msg = input.Receive
(owner.timeouts.ReceiveTimeout);
- if (IsMessageFilteredOut (msg)) {
-Console.WriteLine ("Input message was filtered out.");
- // FIXME: will we need to do something
(like error logging) here.
- return;
- }
- using (OperationContextScope scope = new
OperationContextScope (cch)) {
-
OperationContext.Current.EndpointDispatcher = owner.endpoint_dispatcher;
- rt.ProcessInput (msg);
- }
- }
-
- bool IsMessageFilteredOut (Message req)
- {
- Uri to = req.Headers.To;
- if (to == null)
- return false;
- if (to.AbsoluteUri == Constants.WsaAnonymousUri)
- return false;
- return
!owner.endpoint_dispatcher.AddressFilter.Match (req);
- }
-
void StopLoop ()
{
loop = false;
// FIXME: send manual stop for reply or input
channel.
}
-
- Message CreateDestinationUnreachable (Message req)
- {
- FaultCode fc = new FaultCode (
- "DestinationUnreachable",
- req.Version.Addressing.Namespace);
- // FIXME: set correct namespace URI
- return Message.CreateMessage (req.Version, fc,
- String.Format ("No endpoint found for
message with To '{0}'", req.Headers.To), String.Empty);
- }
-
}
#region AsyncResult classes
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs
2007-03-07 08:35:59 UTC (rev 73871)
@@ -220,38 +220,5 @@
get { return unhandled_dispatch_oper; }
set { unhandled_dispatch_oper = value; }
}
-
- internal void ProcessRequest (RequestContext rctx, TimeSpan
sendTimeout)
- {
- Message req = rctx.RequestMessage;
- DispatchOperation op = GetOperation (req);
- Message res = op.ProcessRequest (req);
- if (res == null)
- throw new InvalidOperationException
(String.Format ("The operation '{0}' returned a null message.", op.Action));
- rctx.Reply (res, sendTimeout);
- }
-
- internal void ProcessInput (Message msg)
- {
- DispatchOperation op = GetOperation (msg);
- op.ProcessInput (msg);
- }
-
- DispatchOperation GetOperation (Message input)
- {
- if (OperationSelector != null) {
- string name = OperationSelector.SelectOperation
(ref input);
- foreach (DispatchOperation d in operations)
- if (d.Name == name)
- return d;
- } else {
- string action = input.Headers.Action;
- foreach (DispatchOperation d in operations)
- if (d.Action == action)
- return d;
- }
-
- return UnhandledDispatchOperation;
- }
}
}
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
2007-03-07 05:31:39 UTC (rev 73870)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
2007-03-07 08:35:59 UTC (rev 73871)
@@ -114,5 +114,116 @@
get { return filter_priority; }
set { filter_priority = value; }
}
+
+ #region communication processing
+
+ internal void ProcessRequest (IReplyChannel reply)
+ {
+ try {
+ DoProcessRequest (reply);
+ } catch (Exception ex) {
+Console.WriteLine (ex);
+ // FIXME: will we need to do something (like
error logging) here.
+ }
+ }
+
+ void DoProcessRequest (IReplyChannel reply)
+ {
+ ServiceEndpoint se = channel_dispatcher.FindEndpoint ();
+ IServiceChannel cch = new ServiceRuntimeChannel (se,
reply);
+ // FIXME: some kind of extra consideration to
+ // create transport-level RequestContext is
+ // needed, to handle errors on wrapping
+ // RequestContext layers (such as
+ // SecurityRequestContext). Currently there
+ // is no way to catch those errors and return
+ // it as SOAP Fault...
+ RequestContext rc = reply.ReceiveRequest
(se.Binding.ReceiveTimeout);
+ if (rc == null)
+ // FIXME: probably some kind of reporting is
required.
+ return;
+ if (IsMessageFilteredOut (rc.RequestMessage)) {
+ rc.Reply (CreateDestinationUnreachable
(rc.RequestMessage));
+ // FIXME: probably some kind of reporting is
required.
+ return;
+ }
+ using (OperationContextScope scope = new
OperationContextScope (cch)) {
+ OperationContext.Current.EndpointDispatcher =
this;
+ OperationContext.Current.RequestContext = rc;
+
+ Message req = rc.RequestMessage;
+ DispatchOperation op = GetOperation (req);
+ Message res = op.ProcessRequest (req);
+ if (res == null)
+ throw new InvalidOperationException
(String.Format ("The operation '{0}' returned a null message.", op.Action));
+ rc.Reply (res, se.Binding.SendTimeout);
+ }
+ }
+
+ internal void ProcessInput (IInputChannel input)
+ {
+ try {
+ DoProcessInput (input);
+ } catch (Exception ex) {
+Console.WriteLine (ex);
+ // FIXME: will we need to do something (like error
logging) here.
+ }
+ }
+
+ void DoProcessInput (IInputChannel input)
+ {
+ ServiceEndpoint se = channel_dispatcher.FindEndpoint ();
+ IServiceChannel cch = new ServiceRuntimeChannel (se,
input);
+ Message msg = input.Receive (se.Binding.ReceiveTimeout);
+ if (IsMessageFilteredOut (msg)) {
+Console.WriteLine ("Input message was filtered out.");
+ // FIXME: will we need to do something (like
error logging) here.
+ return;
+ }
+ using (OperationContextScope scope = new
OperationContextScope (cch)) {
+ OperationContext.Current.EndpointDispatcher =
this;
+ DispatchOperation op = GetOperation (msg);
+ op.ProcessInput (msg);
+ }
+ }
+
+ bool IsMessageFilteredOut (Message req)
+ {
+ Uri to = req.Headers.To;
+ if (to == null)
+ return false;
+ if (to.AbsoluteUri == Constants.WsaAnonymousUri)
+ return false;
+ return !AddressFilter.Match (req);
+ }
+
+ DispatchOperation GetOperation (Message input)
+ {
+ if (DispatchRuntime.OperationSelector != null) {
+ string name =
DispatchRuntime.OperationSelector.SelectOperation (ref input);
+ foreach (DispatchOperation d in
DispatchRuntime.Operations)
+ if (d.Name == name)
+ return d;
+ } else {
+ string action = input.Headers.Action;
+ foreach (DispatchOperation d in
DispatchRuntime.Operations)
+ if (d.Action == action)
+ return d;
+ }
+
+ return DispatchRuntime.UnhandledDispatchOperation;
+ }
+
+ Message CreateDestinationUnreachable (Message req)
+ {
+ FaultCode fc = new FaultCode (
+ "DestinationUnreachable",
+ req.Version.Addressing.Namespace);
+ // FIXME: set correct namespace URI
+ return Message.CreateMessage (req.Version, fc,
+ String.Format ("No endpoint found for message
with To '{0}'", req.Headers.To), String.Empty);
+ }
+
+ #endregion
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches