Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>1) create a class library and sign it with strong key.</p> <p>2)create RoutingServiceBehavior class this class will implement IServiceBehavior, IDispatchMessageInspector interfaces, the code for message interception will be in this class:</p> <pre><code>using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; namespace Services.RoutingServiceBehavior { public class RoutingServiceBehavior : IServiceBehavior, IDispatchMessageInspector { public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { // This is your envelop string s = request.ToString(); return null; } public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { } public void AddBindingParameters(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection&lt;ServiceEndpoint&gt; endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) { } public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) { foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints) { endpointDispatcher.DispatchRuntime.MessageInspectors.Add(this); } } } public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { } } } </code></pre> <p>3) Create RoutingServiceBehaviorElement class, this class will implement BehaviorExtensionElement interface:</p> <pre><code>using System; using System.ServiceModel.Configuration; namespace Services.RoutingServiceBehavior { public class RoutingServiceBehaviorElement : BehaviorExtensionElement { public override Type BehaviorType { get { return typeof(RoutingServiceBehavior); } } protected override object CreateBehavior() { return new RoutingServiceBehavior(); } } } </code></pre> <p>4)Build your project.<br/> 5)Add your assembly to GAC.<br/> 6)Open machine.config and add the name of your assembly under <code>&lt;behaviorExtensions&gt;</code> it shall look like that:</p> <pre><code>&lt;add name="RoutingServiceBehavior" type="Services.RoutingServiceBehavior.RoutingServiceBehaviorElement, Services.RoutingServiceBehavior, Version=1.0.0.0, Culture=neutral" /&gt; </code></pre> <p>7) add the name of your service behavior in your wcf service under <code>&lt;serviceDebug&gt;</code></p> <pre><code>&lt;RoutingServiceBehavior/&gt; </code></pre> <p>8)Make sure that the assembly dlls are included in your WCF service.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload