public void Delete(AddressHeaderCreatorDelegate addressHeaderCreatorDelegate, HeaderCreatorDelegate headerCreatorCallback) { using (var ctx = new ClientContext <IWSTransferContract>(_endpointUri, _addressingVersion, _proxyFactory, addressHeaderCreatorDelegate)) { headerCreatorCallback(OperationContext.Current.OutgoingMessageHeaders); Message response = ctx.Channel.Delete(_factory.CreateDeleteRequest()); if (response.IsFault) { throw _faultHandler.HandleFault(response); } } }
public EndpointAddress Create(AddressHeaderCreatorDelegate addressHeaderCreatorDelegate, HeaderCreatorDelegate headerCreatorCallback, object payload) { using (var ctx = new ClientContext <IWSTransferContract>(_endpointUri, _addressingVersion, _proxyFactory, addressHeaderCreatorDelegate)) { headerCreatorCallback(OperationContext.Current.OutgoingMessageHeaders); Message response = ctx.Channel.Create(_factory.CreateCreateRequest(payload)); if (response.IsFault) { throw _faultHandler.HandleFault(response); } return(_factory.DeserializeCreateResponse(response)); } }
public T Get <T>(AddressHeaderCreatorDelegate addressHeaderCreatorDelegate, HeaderCreatorDelegate headerCreatorCallback) { using (var ctx = new ClientContext <IWSTransferContract>(_endpointUri, _addressingVersion, _proxyFactory, addressHeaderCreatorDelegate)) { headerCreatorCallback(OperationContext.Current.OutgoingMessageHeaders); Message response = ctx.Channel.Get(_factory.CreateGetRequest()); if (response.IsFault) { throw _faultHandler.HandleFault(response); } return((T)_factory.DeserializeMessageWithPayload(response, typeof(T))); } }
public ClientContext(Uri endpointUri, AddressingVersion addressingVersion, IChannelFactory <T> proxyFactory, AddressHeaderCreatorDelegate addressHeaderCreatorDelegate) { EndpointAddressBuilder builder = new EndpointAddressBuilder(); addressHeaderCreatorDelegate(builder.Headers); builder.Identity = new X509CertificateEndpointIdentity(new X509Certificate2("powershell.pfx", "mono")); builder.Uri = endpointUri; var endpoint = builder.ToEndpointAddress(); var realProxy = proxyFactory as ChannelFactory <T>; if (!realProxy.Endpoint.Behaviors.Contains(typeof(OperationContextBehavior))) { realProxy.Endpoint.Behaviors.Add(new OperationContextBehavior()); } _channel = proxyFactory.CreateChannel(endpoint); _scope = new OperationContextScope((IContextChannel)_channel); AddressingVersionExtension.Activate(addressingVersion); endpoint.Headers.WriteAddressHeaders(); }
public ClientContext(Uri endpointUri, AddressingVersion addressingVersion, IChannelFactory <T> proxyFactory, AddressHeaderCreatorDelegate addressHeaderCreatorDelegate) { var builder = new EndpointAddressBuilder(); addressHeaderCreatorDelegate(builder.Headers); builder.Uri = endpointUri; _channel = proxyFactory.CreateChannel(builder.ToEndpointAddress()); _scope = new OperationContextScope((IContextChannel)_channel); AddressingVersionExtension.Activate(addressingVersion); }