Provides a means of customizing a WCF proxy used to communicate with the BOS.
Syntax
Visual Basic (Declaration) | |
---|
<DefaultExportAttribute(IsDefault=True,
ContractName="",
ContractType=IdeaBlade.EntityModel.ServiceProxyEvents)>
Public Class ServiceProxyEvents |
C# | |
---|
[DefaultExportAttribute(IsDefault=true,
ContractName="",
ContractType=IdeaBlade.EntityModel.ServiceProxyEvents)]
public class ServiceProxyEvents |
C++/CLI | |
---|
[DefaultExportAttribute(IsDefault=true,
ContractName="",
ContractType=IdeaBlade.EntityModel.ServiceProxyEvents)]
public ref class ServiceProxyEvents |
Example
C# | Copy Code |
---|
using System;
using System.ComponentModel.Composition;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using IdeaBlade.EntityModel;
public class MyServiceProxyEvents : ServiceProxyEvents {
// Called after an endpoint is created.
public override void OnEndpointCreated(ServiceEndpoint endpoint) {
// Here we'll tweak the binding to add security.
// Bindings used in DevForce are by default the CustomBinding type.
// Remember that bindings on both the client and server must correspond
// for communications to take place.
if (endpoint.Binding is CustomBinding) {
var binding = endpoint.Binding as CustomBinding;
var elements = binding.CreateBindingElements();
// Add transport security.
var transport = elements.Find<TransportBindingElement>();
if (transport.Scheme != "https") {
elements.Remove(transport);
transport = new HttpsTransportBindingElement();
elements.Add(transport);
}
var sec = new TransportSecurityBindingElement();
elements.Insert(1, sec);
// Replace the binding on the endpoint.
endpoint.Binding = new CustomBinding(elements);
var uri = endpoint.Address.Uri;
var newUri = uri.AbsoluteUri.Replace("http", "https");
endpoint.Address = new System.ServiceModel.EndpointAddress(newUri);
}
// Let's change the default timeouts too.
endpoint.Binding.ReceiveTimeout = new TimeSpan(0, 2, 0);
endpoint.Binding.SendTimeout = new TimeSpan(0, 2, 0);
}
// Called before a channel is created and opened from the ChannelFactory.
public override void OnFactoryCreated(System.ServiceModel.ChannelFactory factory) {
factory.Credentials.UserName.UserName = "name";
factory.Credentials.UserName.Password = "pwd";
}
} |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also