Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
 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)));
     }
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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);
        }