/// <summary>
        /// Creates an instance of the Subscription manager class.
        /// </summary>
        /// <remarks>
        /// The device manages an instance of this class on behalf of the device. A device developer
        /// must use the static Device.SubScriptionMgr.FireEvent method to fire events from an event
        /// source.
        /// </remarks>
        public DpwsWseSubscriptionMgr(Binding binding, ProtocolVersion version)
        {
            m_binding = binding.Clone();
            m_version = version;

            m_reqChannel = binding.CreateClientChannel(new ClientBindingContext(version));
        }
        public SimpleServiceClientProxy(Binding binding, ProtocolVersion version) : 
                base(binding, version)
        {

            // Set client endpoint address
            m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));
        }
 internal RequestChannelBinder(IRequestChannel channel)
 {
     if (channel == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     this.channel = channel;
 }
 internal RequestChannelBinder(IRequestChannel channel)
 {
     if (channel == null)
     {
         Fx.Assert("RequestChannelBinder.RequestChannelBinder: (channel != null)");
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     _channel = channel;
 }
 public DurableInstanceContextRequestChannel(ChannelManagerBase channelManager,
     ContextType contextType,
     IRequestChannel innerChannel,
     string contextStoreLocation)
     : base(channelManager, innerChannel)
 {
     this.contextType = contextType;
     this.innerRequestChannel = innerChannel;
     this.contextStoreLocation = contextStoreLocation;
     this.endpointAddress = innerChannel.RemoteAddress;
 }
        public EventingServiceClientProxy(Binding binding, ProtocolVersion version, IEventingServiceCallback callbackHandler) : 
                base(binding, version)
        {
            // Set the client callback implementation property
            m_eventHandler = callbackHandler;

            // Set client endpoint address
            m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));

            // Add client callback operations and event source types
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "SimpleEvent"));
            EventSources.Add(new DpwsServiceType("SimpleEvent", "http://schemas.example.org/EventingService"));
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "IntegerEvent"));
            EventSources.Add(new DpwsServiceType("IntegerEvent", "http://schemas.example.org/EventingService"));
        }
        public EventingServiceClientProxy(Binding binding, ProtocolVersion version, IEventingServiceCallback callbackHandler) : 
                base(binding, version)
        {
            // Set the client callback implementation property
            m_eventHandler = callbackHandler;

            // Set client endpoint address
            m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));

            // Add client callback operations and event source types
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "SimpleEvent"));
            EventSources.Add(new DpwsServiceType("SimpleEvent", "http://schemas.example.org/EventingService"));
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "IntegerEvent"));
            EventSources.Add(new DpwsServiceType("IntegerEvent", "http://schemas.example.org/EventingService"));

            // Add eventing SubscriptionEnd ServiceOperations. By default Subscription End call back to this client
            ServiceOperations.Add(new WsServiceOperation(WsWellKnownUri.WseNamespaceUri, "SubscriptionEnd"));

            this.StartEventListeners();
        }
 public AttachmentServiceClientProxy(Binding binding, ProtocolVersion version) :
     base(binding, version)
 {
     // Set client endpoint address
     m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));
 }
Example #9
0
        // It is almost identical to http-low-level-binding
        public void LowLevelHttpConnection()
        {
            HttpTransportBindingElement lel =
                new HttpTransportBindingElement();

            // Service
            BindingContext lbc = new BindingContext(
                new CustomBinding(),
                new BindingParameterCollection(),
                new Uri("http://localhost:" + NetworkHelpers.FindFreePort()),
                String.Empty, ListenUriMode.Explicit);

            listener = lel.BuildChannelListener <IReplyChannel> (lbc);

            try {
                listener.Open();

                svcret = "";

                Thread svc = new Thread(delegate() {
                    try {
                        svcret = LowLevelHttpConnection_SetupService();
                    } catch (Exception ex) {
                        svcret = ex.ToString();
                    }
                });
                svc.Start();

                // Client code goes here.

                HttpTransportBindingElement el =
                    new HttpTransportBindingElement();
                BindingContext ctx = new BindingContext(
                    new CustomBinding(),
                    new BindingParameterCollection());
                IChannelFactory <IRequestChannel> factory =
                    el.BuildChannelFactory <IRequestChannel> (ctx);

                factory.Open();

                IRequestChannel request = factory.CreateChannel(
                    new EndpointAddress("http://localhost:" + NetworkHelpers.FindFreePort()));

                request.Open();

                try {
                    try {
                        Message reqmsg = Message.CreateMessage(
                            MessageVersion.Default, "Echo");
                        // sync version does not work here.
                        Message msg = request.Request(reqmsg, TimeSpan.FromSeconds(5));

                        using (XmlWriter w = XmlWriter.Create(TextWriter.Null)) {
                            msg.WriteMessage(w);
                        }

                        if (svcret != null)
                        {
                            Assert.Fail(svcret.Length > 0 ? svcret : "service code did not finish until this test expected.");
                        }
                    } finally {
                        if (request.State == CommunicationState.Opened)
                        {
                            request.Close();
                        }
                    }
                } finally {
                    if (factory.State == CommunicationState.Opened)
                    {
                        factory.Close();
                    }
                }
            } finally {
                if (listener.State == CommunicationState.Opened)
                {
                    listener.Close();
                }
            }
        }
 public MyRequestChannel(ChannelManagerBase channleManager, IRequestChannel innerChannel)
     : base(channleManager)
 {
     this.InnerChannel = innerChannel;
 }
        public void MessageSecurityManualProtection()
        {
            SymmetricSecurityBindingElement sbe =
                new SymmetricSecurityBindingElement();

            sbe.ProtectionTokenParameters =
                new X509SecurityTokenParameters();
            RequestSender sender = delegate(Message input)
            {
                MessageBuffer buf = input.CreateBufferedCopy(0x10000);
                using (XmlWriter w = XmlWriter.Create(Console.Error))
                {
                    buf.CreateMessage().WriteMessage(w);
                }
                return(buf.CreateMessage());
            };

            CustomBinding binding = new CustomBinding(
                sbe,
                new TextMessageEncodingBindingElement(),
                new HandlerTransportBindingElement(sender));

            EndpointAddress address = new EndpointAddress(
                new Uri("http://localhost:37564"),
                new X509CertificateEndpointIdentity(new X509Certificate2("Test/Resources/test.pfx", "mono")));

            ChannelProtectionRequirements reqs =
                new ChannelProtectionRequirements();

            reqs.OutgoingSignatureParts.AddParts(
                new MessagePartSpecification(new XmlQualifiedName("SampleValue", "urn:foo")), "urn:myaction");
            BindingParameterCollection parameters =
                new BindingParameterCollection();

            parameters.Add(reqs);

            /*
             *                      SymmetricSecurityBindingElement innersbe =
             *                              new SymmetricSecurityBindingElement ();
             *                      innersbe.ProtectionTokenParameters =
             *                              new X509SecurityTokenParameters ();
             *                      sbe.ProtectionTokenParameters =
             *                              new SecureConversationSecurityTokenParameters (
             *                                      innersbe, false, reqs);
             */

            IChannelFactory <IRequestChannel> cf =
                binding.BuildChannelFactory <IRequestChannel> (parameters);

            cf.Open();
            IRequestChannel ch = cf.CreateChannel(address);

            ch.Open();
            try
            {
                ch.Request(Message.CreateMessage(MessageVersion.None, "urn:myaction", new SampleValue()));
            }
            finally
            {
                ch.Close();
            }
        }
Example #12
0
        public Task AsynchronousInvoke(
            IRequestChannel channel,
            TChannelBufferInputTransport inputTransport,
            TChannelBufferOutputTransport outputTransport,
            TProtocol inputProtocol,
            TProtocol outputProtocol,
            int sequenceId,
            ClientContextChain contextChain,
            Object[] args)
        {
            //Mark: 微软没有提供 TaskCompletionSource 的非泛型类型,只能使用动态类型处理。
            TaskCompletionSourceEx future;

            if (_successCodec.Type != ThriftType.Void)
            {
                future = new TaskCompletionSourceEx(_successCodec.Type.CSharpType);
            }
            else
            {
                future = new TaskCompletionSourceEx(typeof(Object));
            }
            var requestContext = RequestContexts.GetCurrentContext();

            contextChain.PreWrite(args);
            outputTransport.ResetOutputBuffer();
            WriteArguments(outputProtocol, sequenceId, args);
            IByteBuffer requestBuffer = outputTransport.OutputBuffer.Copy();

            contextChain.PostWrite(args);

            requestBuffer.Retain();
            channel.SendAsynchronousRequest(requestBuffer, false,
                                            new RequestListener(
                                                onRequestSent: reqs =>
            {
                reqs.Release();
                if (this._oneway)
                {
                    try
                    {
                        ForceDoneChain(contextChain);
                        future.TrySetResult(null);
                    }
                    catch (Exception e)
                    {
                        ForceDoneChain(contextChain);
                        future.TrySetException(e);
                    }
                }
            },
                                                onResponseReceive: message =>
            {
                IRequestContext oldRequestContext = RequestContexts.GetCurrentContext();
                RequestContexts.SetCurrentContext(requestContext);
                try
                {
                    contextChain.PreRead();
                    inputTransport.SetInputBuffer(message);
                    WaitForResponse(inputProtocol, sequenceId);
                    Object results = ReadResponse(inputProtocol);
                    contextChain.PostRead(results);
                    ForceDoneChain(contextChain);
                    future.TrySetResult(results);
                }
                catch (Exception e)
                {
                    var wrapException = ThriftClientManager.WrapTException(e);
                    contextChain.PostReadException(e);
                    ForceDoneChain(contextChain);
                    future.TrySetException(wrapException);
                }
                finally
                {
                    RequestContexts.SetCurrentContext(oldRequestContext);
                }
            },
                                                onChannelError: e =>
            {
                if (requestBuffer.ReferenceCount > 0)
                {
                    requestBuffer.Release();
                }

                IRequestContext oldRequestContext = RequestContexts.GetCurrentContext();
                RequestContexts.SetCurrentContext(requestContext);
                try
                {
                    contextChain.PreReadException(e);
                    ForceDoneChain(contextChain);

                    var wrappedException = ThriftClientManager.WrapTException(e);
                    future.TrySetException(wrappedException);
                }
                finally
                {
                    RequestContexts.SetCurrentContext(oldRequestContext);
                }
            }
                                                ));
            return(future.Task);
        }
Example #13
0
 protected override void OnPrepare()
 {
     base.OnPrepare();
     this.Channel = this.Client.Channel;
 }
Example #14
0
 protected SecurityRequestChannelBase(IRequestChannel innerChannel)
     : base(innerChannel)
 {
     Opened  += new EventHandler(AcquireSecurityKey);
     Closing += new EventHandler(ReleaseSecurityKey);
 }
Example #15
0
 public LayeredRequestChannel(IRequestChannel source)
     : base(source)
 {
     inner = source;
 }
Example #16
0
 protected override void OnOpen(TimeSpan timeout)
 {
     inner = CreateDiscoveryInnerChannel <IRequestChannel> (factory);
 }
 public SimpleRequestChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel)
     : base(channelManager, (ChannelBase)innerChannel)
 {
     this.Print("SimpleRequestChannel()");
 }
 internal EventChannel(IRequestChannel chan)
 {
     RefCount = 1;
     Channel = chan;
 }
Example #19
0
        private static async Task SendRequest(IRequestChannel request, string message)
        {
            var response = await request.RequestAsync(Encoding.UTF8.GetBytes(message));

            Console.WriteLine(Encoding.UTF8.GetString(response));
        }
Example #20
0
 public CustomHeaderChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel, IClientCustomHeader customHeader)
     : base(channelManager)
 {
     this.m_innerChannel = innerChannel;
     this.m_customHeader = customHeader;
 }
 public HttpAcknowledgementOutputChannel(IRequestChannel inner, HttpAcknowledgementChannelFactory creator)
     : base(creator)
 {
     this.innerChannel = inner;
 }
 public CustomHeaderChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel, IClientCustomHeader  customHeader)
     : base(channelManager)
 {
     this.m_innerChannel = innerChannel;
     this.m_customHeader = customHeader;
 }
Example #23
0
 public SecurityRequestChannel(ChannelManagerBase factory, SecurityProtocolFactory securityProtocolFactory, IRequestChannel innerChannel, EndpointAddress to, Uri via)
     : base(factory, securityProtocolFactory, innerChannel, to, via)
 {
 }
        public void AsynchronousRequest()
        {
            byte[] data   = new byte[36];
            Random rndGen = new Random();

            rndGen.NextBytes(data);

            Message input = Formatting.BytesToMessage(data);

            ManualResetEvent evt = new ManualResetEvent(false);
            Uri    serverUri     = new Uri(SizedTcpTransportBindingElement.SizedTcpScheme + "://" + Environment.MachineName + ":" + Port);
            object channel       = ReflectionHelper.CreateInstance(
                typeof(SizedTcpTransportBindingElement),
                "JsonRpcOverTcp.Channels.SizedTcpRequestChannel",
                new ByteStreamMessageEncodingBindingElement().CreateMessageEncoderFactory().Encoder,
                BufferManager.CreateBufferManager(int.MaxValue, int.MaxValue),
                Mocks.GetChannelManagerBase(),
                new EndpointAddress(serverUri),
                serverUri);

            ChannelBase     channelBase    = (ChannelBase)channel;
            IRequestChannel requestChannel = (IRequestChannel)channel;

            channelBase.Open();

            object state   = new object();
            bool   success = true;

            requestChannel.BeginRequest(input, new AsyncCallback(delegate(IAsyncResult asyncResult)
            {
                try
                {
                    if (!Object.ReferenceEquals(asyncResult.AsyncState, state))
                    {
                        success = false;
                        Console.WriteLine("Error, state not preserved");
                    }
                    else
                    {
                        Message output = requestChannel.EndRequest(asyncResult);

                        try
                        {
                            byte[] outputBytes = Formatting.MessageToBytes(output);
                            Assert.Equal(data, outputBytes, new ArrayComparer <byte>());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Error: " + e);
                            success = false;
                        }
                    }
                }
                finally
                {
                    evt.Set();
                }
            }), state);

            evt.WaitOne();
            Assert.True(success, "Error in callback");
            channelBase.Close();
        }
 protected override bool HasSecuritySession(IRequestChannel channel)
 {
     return(false);
 }
Example #26
0
 public SecurityRequestChannel(IRequestChannel innerChannel, SecurityChannelFactory <IRequestChannel> source)
     : base(innerChannel)
 {
     this.source = source;
     InitializeSecurityFunctionality(source.SecuritySupport);
 }
        /// <summary>
        /// Removes one or more MonitoredItems of a Subscription.
        /// </summary>
        /// <param name="channel">A instance of <see cref="IRequestChannel"/>.</param>
        /// <param name="request">A <see cref="DeleteMonitoredItemsRequest"/>.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation that returns a <see cref="DeleteMonitoredItemsResponse"/>.</returns>
        /// <seealso href="https://reference.opcfoundation.org/v104/Core/docs/Part4/5.12.6/">OPC UA specification Part 4: Services, 5.12.6</seealso>
        public static async Task <DeleteMonitoredItemsResponse> DeleteMonitoredItemsAsync(this IRequestChannel channel, DeleteMonitoredItemsRequest request, CancellationToken token = default)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return((DeleteMonitoredItemsResponse)await channel.RequestAsync(request, token).ConfigureAwait(false));
        }
 internal EventChannel(IRequestChannel chan)
 {
     RefCount = 1;
     Channel  = chan;
 }
 public MessageInspectorChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel, IClientMessageInspector messageInspector)
     : base(channelManager)
 {
     this.innerChannel     = innerChannel;
     this.messageInspector = messageInspector;
 }
Example #30
0
        private Object SynchronousInvoke(
            IRequestChannel channel,
            TChannelBufferInputTransport inputTransport,
            TChannelBufferOutputTransport outputTransport,
            TProtocol inputProtocol,
            TProtocol outputProtocol,
            int sequenceId,
            ClientContextChain contextChain,
            Object[] args)
        {
            Object results = null;

            // write request
            contextChain.PreWrite(args);
            outputTransport.ResetOutputBuffer();
            WriteArguments(outputProtocol, sequenceId, args);
            // Don't need to copy the output buffer for sync case

            IByteBuffer requestBuffer = outputTransport.OutputBuffer;

            contextChain.PostWrite(args);

            if (!this._oneway)
            {
                IByteBuffer responseBuffer;
                try
                {
                    responseBuffer = SyncClientHelpers.SendSynchronousTwoWayMessage(channel, requestBuffer);
                }
                catch (Exception e)
                {
                    contextChain.PreReadException(e);
                    throw;
                }
                finally
                {
                    requestBuffer.Release();
                }

                // read results
                contextChain.PreRead();
                try
                {
                    inputTransport.SetInputBuffer(responseBuffer);
                    WaitForResponse(inputProtocol, sequenceId);
                    results = ReadResponse(inputProtocol);
                    contextChain.PostRead(results);
                }
                catch (Exception e)
                {
                    contextChain.PostReadException(e);
                    throw;
                }
            }
            else
            {
                try
                {
                    SyncClientHelpers.SendSynchronousOneWayMessage(channel, requestBuffer);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(results);
        }
 public ProtoBufMetaDataRequestChannel(ChannelManagerBase parent, IRequestChannel innerChannel) :
     base(parent, innerChannel)
 {
     _innerChannel = innerChannel;
 }
        /// <summary>
        /// Translates one or more browse paths to NodeIds.
        /// </summary>
        /// <param name="channel">A instance of <see cref="IRequestChannel"/>.</param>
        /// <param name="request">A <see cref="TranslateBrowsePathsToNodeIdsRequest"/>.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation that returns a <see cref="TranslateBrowsePathsToNodeIdsResponse"/>.</returns>
        /// <seealso href="https://reference.opcfoundation.org/v104/Core/docs/Part4/5.8.4/">OPC UA specification Part 4: Services, 5.8.4</seealso>
        public static async Task <TranslateBrowsePathsToNodeIdsResponse> TranslateBrowsePathsToNodeIdsAsync(this IRequestChannel channel, TranslateBrowsePathsToNodeIdsRequest request, CancellationToken token = default)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return((TranslateBrowsePathsToNodeIdsResponse)await channel.RequestAsync(request, token).ConfigureAwait(false));
        }
Example #33
0
 public SimpleRequestChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel) : base(channelManager)
 {
     _innerChannel = innerChannel;
 }
Example #34
0
        public async Task Main(string[] args)
        {
            if (args.Length != 3)
            {
                var done = await Task.Run(() =>
                {
                    WriteLine($"{Environment.NewLine} Commands: [Reloc] Is64 Region TimeDateStamp");
                    WriteLine($"\te.g. running the default Reloc command [dnx run True ntdll 51DA4B7D]");
                    WriteLine($"\twill result in the 64bit 7zip compressed reloc data to be downloaded to NTDLL.DLL-78E50000-51DA4B7D.reloc.7z");
                    WriteLine($"\tBy using relocation data during a memory dump extraction, an exact match may be calculated from disk-code<->memory-code.{ Environment.NewLine}");
                    WriteLine($"\tuser provided {args.Length + 1} arguments (only specify 3), interpreted as;");
                    WriteLine($"\tIs64[{(args.Length >= 1 ? args[0] : String.Empty)}] Region[{(args.Length >= 2 ? args[1] : String.Empty)}] TimeDateStamp[{(args.Length >= 3 ? args[2] : String.Empty)}] ...");
                    return(false);
                });

                return;
            }

            var Is64            = false;
            var time            = uint.MinValue;
            var Region          = string.Empty;
            var dt              = DateTime.MinValue;
            var KnownAsName     = string.Empty;
            var OrigLoadAddress = ulong.MinValue;

            if (!bool.TryParse(args[0], out Is64))
            {
                WriteLine($"Error parsing a booliean value (True or False) from [{args[0]}], unable to continue.");
                return;
            }

            Region = args[1];
            if (string.IsNullOrWhiteSpace(Region) || Region.Contains(Path.GetInvalidFileNameChars().ToString()))
            {
                WriteLine($"Must provide a value for the DLL/EXE name to search for (region), provided value [{args[1]}], unable to continue.");
                return;
            }

            if (!uint.TryParse(args[2], NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out time)
                &&
                !uint.TryParse(args[2], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out time)
                &&
                !DateTime.TryParse(args[2], out dt)
                )
            {
                WriteLine($"Error parsing a TimeDateStamp value (numeric (hex allowed) or in text form e.g. (8/18/2010 1:30:30 PM - 1/1/2010 8:00:15 AM = 229.05:30:15) from [{args[2]}], unable to continue.");
                return;
            }
            // if the argument was not a number or string value for date
            // maybe it's a filename to use as a reference? ;)??
            if (dt == DateTime.MinValue && time == uint.MinValue)
            {
                time = PETimeDateStamp(args[2]);
            }

            // The FinalFileName is only known after the server responds with additional metadata
            var DestName = $"{Region}-?####?-{time:X}.reloc.7z";

            WriteLine($"Contacting, dest file [{DestName}]: 64bit:{Is64}, Region(dll):{Region}, TimeDateStamp:{time:X}.");

            InterWeb          = new Net("http://blockwatch.ioactive.com:8888/");
            InterWeb.UserName = "******";
            InterWeb.PassWord = "******";

            //
            // Sending the "Online" packet dosent really matter since the cred's are sent always.
            // It's more of an application ping/test that you're good to go.
            //
            // Aside from the downloaded .reloc file.  You will also get the preferred load address
            // which can sometimes be missing or altered by due to loader artifacts ? :(
            //

            var FinalFileName =
                await Task.Factory.StartNew(() => InterWeb.Online())
                .ContinueWith((isOn) =>
            {
                Task <byte[]> data = null;
                if (isOn.Result)
                {
                    data = Task.Factory.StartNew(() => InterWeb.NetRelocCheck(Region, time, Is64, ref OrigLoadAddress, ref KnownAsName));
                }
                return(data);
            }).Unwrap().ContinueWith((bytez) =>
            {
                var FinalName = $"{KnownAsName}-{OrigLoadAddress:X}-{time:X}.reloc.7z";
                File.WriteAllBytes(FinalName, bytez.Result);
                return(FinalName);
            });

            if (OrigLoadAddress == ulong.MaxValue)
            {
                Write("An error reported from server: ");
            }

            if (File.Exists(FinalFileName))
            {
                WriteLine($"Downloaded to {FinalFileName}, size {new FileInfo(FinalFileName).Length}.");
            }
            else
            {
                WriteLine("No .reloc available, request an import of the reloc data you need, we will expand the table based on feedback.");
            }

            return;

#if FALSE
            var LC = new LoginCredsText()
            {
                username = InterWeb.UserName, password = InterWeb.PassWord
            };
            WriteLine("test1...");
            IChannelFactory <IRequestChannel> factory = new BasicHttpBinding().BuildChannelFactory <IRequestChannel>(new BindingParameterCollection());
            factory.Open();
            IRequestChannel channel = factory.CreateChannel(new EndpointAddress("http://blockwatch.ioactive.com:8888/Buffer/Text/wsHttp"));
            channel.Open();
            Message requestmessage = Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IElmerBuffer/Online", LC, new DataContractSerializer(LC.GetType()));
            //send message
            Message replymessage = channel.Request(requestmessage);
            WriteLine("Reply message received");
            WriteLine("Reply action: {0}", replymessage.Headers.Action);
            string data = replymessage.GetBody <string>();
            WriteLine("Reply content: {0}", data);
            //Step5: don't forget to close the message
            requestmessage.Close();
            replymessage.Close();
            //don't forget to close the channel
            channel.Close();
            //don't forget to close the factory
            factory.Close();
#endif
        }
Example #35
0
		public SecurityRequestChannel (IRequestChannel innerChannel, SecurityChannelFactory<IRequestChannel> source)
			: base (innerChannel)
		{
			this.source = source;
			InitializeSecurityFunctionality (source.SecuritySupport);
		}
Example #36
0
        protected override IOutputChannel OnCreateChannel(EndpointAddress to, Uri via)
        {
            IRequestChannel innerChannel = innerFactory.CreateChannel(to, via);

            return(new HttpAcknowledgementOutputChannel(innerChannel, this));
        }
 public WebClientFactory(Subscription subscription, IRequestChannel channel)
 {
     this.subscription = subscription;
     this.channel = channel;
 }
Example #38
0
 public CustomRequestChannel(IRequestChannel innerChannel, CustomBindingElement element)
     : base(innerChannel, element)
 {
     _innerChannel = innerChannel;
 }
Example #39
0
 public SimpleRequestChannel(ChannelManagerBase baseManager, IRequestChannel innerChannel)
     : base(baseManager, (ChannelBase)innerChannel)
 {
 }
 public WebClientFactory(Subscription subscription, IRequestChannel channel)
 {
     this.subscription = subscription;
     this.channel      = channel;
 }
 public DebugRequestChannel(ChannelFactoryBase source, IRequestChannel inner)
     : base(source)
 {
     this.source = source;
     this.inner  = inner;
 }
Example #42
0
 public SimpleRequestChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel)
     : base(channelManager)
 {
     _innerChannel = innerChannel;
 }
Example #43
0
 public MyRequestChannel(ChannelManagerBase channleManager, IRequestChannel innerChannel)
     : base(channleManager)
 {
     this.InnerChannel = innerChannel;
 }
Example #44
0
		protected SecurityRequestChannelBase (IRequestChannel innerChannel)
			: base (innerChannel)
		{
			Opened += new EventHandler (AcquireSecurityKey);
			Closing += new EventHandler (ReleaseSecurityKey);
		}
    public static void ChannelShape_TypedProxy_InvokeIRequestChannelAsync()
    {
        CustomBinding customBinding = null;
        ChannelFactory <IRequestChannel> factory = null;
        EndpointAddress endpointAddress          = null;
        IRequestChannel channel            = null;
        Message         requestMessage     = null;
        Message         replyMessage       = null;
        string          replyMessageAction = null;
        string          actualResponse     = null;

        try
        {
            // *** SETUP *** \\
            customBinding = new CustomBinding(new BindingElement[] {
                new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8),
                new HttpTransportBindingElement()
            });
            endpointAddress = new EndpointAddress(Endpoints.DefaultCustomHttp_Address);
            // Create the channel factory for the request-reply message exchange pattern.
            factory = new ChannelFactory <IRequestChannel>(customBinding, endpointAddress);
            // Create the channel.
            channel = factory.CreateChannel();
            channel.Open();
            // Create the Message object to send to the service.
            requestMessage = Message.CreateMessage(
                customBinding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";

            // *** EXECUTE *** \\
            // Send the Message and receive the Response.
            IAsyncResult ar = channel.BeginRequest(requestMessage, null, null);
            replyMessage       = channel.EndRequest(ar);
            replyMessageAction = replyMessage.Headers.Action;

            // *** VALIDATE *** \\
            Assert.True(String.Equals(replyMessageAction, action + "Response"),
                        String.Format("A response was received from the Service but it was not the expected Action, expected: {0} actual: {1}",
                                      action + "Response", replyMessageAction));

            // *** EXECUTE *** \\
            var replyReader = replyMessage.GetReaderAtBodyContents();
            actualResponse = replyReader.ReadElementContentAsString();

            // *** VALIDATE *** \\
            Assert.True(String.Equals(actualResponse, expectedResponse),
                        String.Format("Actual MessageBodyContent from service did not match the expected MessageBodyContent, expected: {0} actual: {1}",
                                      expectedResponse, actualResponse));

            // *** CLEANUP *** \\
            replyMessage.Close();
            channel.Close();
            factory.Close();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            replyMessage.Close();
            ScenarioTestHelpers.CloseCommunicationObjects(channel, factory);
        }
    }
 public ProtoBufMetaDataRequestChannel(ChannelManagerBase parent, IRequestChannel innerChannel) :
     base(parent, innerChannel)
 {
     _innerChannel = innerChannel;
 }
 public OAuthInterceptorChannel(ChannelManagerBase channelManager, IRequestChannel innerChannel)
     : base(channelManager)
 {
     this.innerChannel = innerChannel;
 }
 public InterceptorRequestChannel(InterceptorChannelFactory <IRequestChannel> source, IRequestChannel inner)
     : base(source)
 {
     this.source = source;
     this.inner  = inner;
 }
 bool OnChannelFactoriesInitialized()
 {
     this.rstChannel          = this.tokenProvider.CreateClientChannel(negotiationState.RemoteAddress, this.via);
     this.nextOutgoingMessage = null;
     return(this.OnRequestChannelCreated());
 }