Exemple #1
0
                private void HttpGetResponseThread()
                {
                    try
                    {
                        // List<IAsyncResult> results = new List<IAsyncResult>();
                        bool isEOM = false;

                        // ProcessResponseDelegate p = ProcessResponses;
                        int responseCount = 0;

                        // while (!isEOM)
                        // {
                        SessionBase.TraceSource.TraceInformation("Begin PullResponse : count {0} : clientId {1}", this.count, this.clientId);
                        BrokerResponseMessages responseMessages = this.controller.PullResponses(this.action, this.resetToBegin, this.count, this.clientId);
                        SessionBase.TraceSource.TraceInformation("End PullResponse : count {0} : isEOM {1}", responseMessages.SOAPMessage.Length, responseMessages.EOM);

                        // responseCount += responseMessages.SOAPMessage.Length;
                        responseCount = responseMessages.SOAPMessage.Length;

                        // results.Add(p.BeginInvoke(responseMessages, clientData, null, null));
                        this.ProcessResponses(responseMessages, this.clientData);
                        Interlocked.Add(ref this.responseClient.totalResponseCount, responseCount);
                        isEOM = responseMessages.EOM;

                        if (isEOM)
                        {
                            // construct endofreponses message
                            TypedMessageConverter converter      = TypedMessageConverter.Create(typeof(EndOfResponses), Constant.EndOfMessageAction);
                            EndOfResponses        endOfResponses = new EndOfResponses();
                            endOfResponses.Count  = this.responseClient.totalResponseCount;
                            endOfResponses.Reason = EndOfResponsesReason.Success;
                            Message eom = converter.ToMessage(endOfResponses, MessageVersion.Soap11);
                            eom.Headers.Add(MessageHeader.CreateHeader(Constant.ResponseCallbackIdHeaderName, Constant.ResponseCallbackIdHeaderNS, this.clientData));

                            this.callback.SendResponse(eom);
                        }
                    }
                    catch (Exception e)
                    {
                        SessionBase.TraceSource.TraceInformation("PullResponse Exception: {0}", e.ToString());

                        if (this.disposeFlag)
                        {
                            return;
                        }

                        Message exceptionMessage = Message.CreateMessage(MessageVersion.Soap11, @"http://hpc.microsoft.com/ClientSideExeption");
                        exceptionMessage.Headers.Add(MessageHeader.CreateHeader(Constant.ResponseCallbackIdHeaderName, Constant.ResponseCallbackIdHeaderNS, this.clientData));
                        exceptionMessage.Properties.Add(@"HttpClientException", e);

                        this.callback.SendResponse(exceptionMessage);
                    }
                    finally
                    {
                        if (this.Completed != null)
                        {
                            this.Completed(this, EventArgs.Empty);
                        }
                    }
                }
Exemple #2
0
 public void ProcessResponses(BrokerResponseMessages responseMessages, string clientData)
 {
     foreach (XmlElement xe in responseMessages.SOAPMessage)
     {
         Message m = null;
         using (MemoryStream ms = new MemoryStream())
         {
             XmlWriter xw = XmlWriter.Create(ms);
             xe.WriteTo(xw);
             xw.Flush();
             ms.Position = 0;
             XmlDictionaryReader reader = XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(ms, new XmlReaderSettings()
             {
                 XmlResolver = null
             }));
             m = Message.CreateMessage(reader, int.MaxValue, MessageVersion.Soap11);
             m.Headers.Add(MessageHeader.CreateHeader(Constant.ResponseCallbackIdHeaderName, Constant.ResponseCallbackIdHeaderNS, clientData));
             this.callback.SendResponse(m);
         }
     }
 }