private PullResponse PullNextBatch(EnumerationContextKey context, int maxElements, IEnumerable <Selector> selectors)
 {
     using (ClientContext <IWSEventingPullDeliveryContract> ctx =
                new ClientContext <IWSEventingPullDeliveryContract>(_endpointUri, _binding.MessageVersion.Addressing, _enumerationProxyFactory,
                                                                    mx =>
     {
         mx.Add(new ResourceUriHeader(_resourceUri));
         mx.Add(new SelectorSetHeader(selectors));
     }))
     {
         FilterMapExtension.Activate(_filterMap);
         EnumerationModeExtension.Activate(EnumerationMode.EnumerateObjectAndEPR, typeof(T));
         try
         {
             return(ctx.Channel.Pull(new PullRequest
             {
                 MaxTime = new MaxTime(TimeSpan.FromSeconds(10)),
                 EnumerationContext = context,
                 MaxElements = new MaxElements(maxElements)
             }));
         }
         catch (FaultException ex)
         {
             if (ex.IsA(Faults.TimedOut))
             {
                 return(new PullResponse {
                     EnumerationContext = context
                 });
             }
             throw;
         }
     }
 }
示例#2
0
        public void Additional_data_in_response_is_ignored()
        {
            const string xml = @"<ns5:PullResponse xmlns:ns3=""http://schemas.xmlsoap.org/ws/2004/08/addressing""
    xmlns:ns4=""http://schemas.xmlsoap.org/ws/2004/08/eventing""
    xmlns:ns5=""http://schemas.xmlsoap.org/ws/2004/09/enumeration""
    xmlns:ns6=""http://schemas.xmlsoap.org/ws/2004/09/transfer""
    xmlns:ns7=""http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd""
    xmlns:ns8=""http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd""
    xmlns:ns9=""http://jsr262.dev.java.net/jmxconnector"">
      <ns5:Items>
        <ns3:EndpointReference>
          <ns3:Address>http://iblongsw573721:10003/</ns3:Address>
          <ns3:ReferenceParameters>
            <ns7:ResourceURI>
            http://jsr262.dev.java.net/DynamicMBeanResource</ns7:ResourceURI>
            <ns7:SelectorSet>
              <ns7:Selector Name=""ObjectName"">
              JMImplementation:type=MBeanServerDelegate</ns7:Selector>
            </ns7:SelectorSet>
          </ns3:ReferenceParameters>
        </ns3:EndpointReference>
      </ns5:Items>
      <ns5:EndOfSequence xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xsi:type=""xs:string""></ns5:EndOfSequence>
    </ns5:PullResponse>";

            AddressingVersionExtension.Activate(AddressingVersion.WSAddressingAugust2004);
            EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
            XmlSerializer xs = new XmlSerializer(typeof(PullResponse), null, new Type[] { typeof(string) }, new XmlRootAttribute("PullResponse")
            {
                Namespace = "http://schemas.xmlsoap.org/ws/2004/09/enumeration"
            }, null);
            object deserializedObject = xs.Deserialize(new StringReader(xml));
        }
        public PullResponse Pull(PullRequest request)
        {
            //TODO: Check URI
            PullSubscription subsciption;

            if (request.EnumerationContext == null || !_subscriptions.TryGetValue(request.EnumerationContext.Text, out subsciption))
            {
                throw Faults.InvalidEnumerationContext.Create();
            }

            EnumerationModeExtension.Activate(EnumerationMode.EnumerateObjectAndEPR, subsciption.EventType);

            int maxElements = request.MaxElements != null
                              ? request.MaxElements.Value
                              : 1;

            TimeSpan maxTime = request.MaxTime != null
            ? request.MaxTime.Value
            : TimeSpan.FromSeconds(10);

            EnumerationItemList items = new EnumerationItemList(PullItems(subsciption.Buffer.FetchNotifications(maxElements, maxTime)));

            //R7.2.13-5
            if (items.Items.Count() == 0)
            {
                throw Faults.TimedOut.Create();
            }
            return(new PullResponse
            {
                Items = items,
                EndOfSequence = null,
                EnumerationContext = request.EnumerationContext
            });
        }
示例#4
0
 private PullResponse PullNextEPRBatch(EnumerationContextKey context, string resourceUri, int maxElements, IEnumerable <Selector> selectors)
 {
     using (ClientContext <IWSEnumerationContract> ctx =
                new ClientContext <IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
                                                           mx =>
     {
         mx.Add(new ResourceUriHeader(resourceUri));
         mx.Add(new SelectorSetHeader(selectors));
     }))
     {
         FilterMapExtension.Activate(_filterMap);
         EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
         return(ctx.Channel.Pull(new PullRequest
         {
             EnumerationContext = context,
             MaxElements = new MaxElements(maxElements)
         }));
     }
 }
示例#5
0
        public IEnumerable <EndpointAddress> EnumerateEPR(Uri resourceUri, Filter filter, int maxElements, IEnumerable <Selector> selectors)
        {
            EnumerateResponse response;

            using (ClientContext <IWSEnumerationContract> ctx =
                       new ClientContext <IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
                                                                  mx =>
            {
                mx.Add(new ResourceUriHeader(resourceUri.ToString()));
                mx.Add(new SelectorSetHeader(selectors));
            }))
            {
                FilterMapExtension.Activate(_filterMap);
                EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
                response = ctx.Channel.Enumerate(new EnumerateRequest
                {
                    EnumerationMode     = EnumerationMode.EnumerateEPR,
                    OptimizeEnumeration = _optimize ? new OptimizeEnumeration() : null,
                    Filter      = filter,
                    MaxElements = new MaxElements(maxElements)
                });
            }
            if (response.Items != null)
            {
                foreach (EnumerationItem item in response.Items.Items)
                {
                    yield return(item.EprValue);
                }
            }
            EnumerationContextKey context = response.EnumerationContext;
            bool endOfSequence            = response.EndOfSequence != null;

            while (!endOfSequence)
            {
                PullResponse pullResponse = PullNextEPRBatch(context, resourceUri.ToString(), maxElements, selectors);
                foreach (EnumerationItem item in pullResponse.Items.Items)
                {
                    yield return(item.EprValue);
                }
                endOfSequence = pullResponse.EndOfSequence != null;
                context       = pullResponse.EnumerationContext;
            }
        }
示例#6
0
 public int EstimateCount(Uri resourceUri, Filter filter, IEnumerable <Selector> selectors)
 {
     using (ClientContext <IWSEnumerationContract> ctx =
                new ClientContext <IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
                                                           mx =>
     {
         mx.Add(new ResourceUriHeader(resourceUri.ToString()));
         mx.Add(new SelectorSetHeader(selectors));
     }))
     {
         OperationContextProxy.Current.AddHeader(new RequestTotalItemsCountEstimate());
         FilterMapExtension.Activate(_filterMap);
         EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
         ctx.Channel.Enumerate(new EnumerateRequest
         {
             EnumerationMode     = EnumerationMode.EnumerateEPR,
             OptimizeEnumeration = _optimize ? new OptimizeEnumeration() : null,
             Filter = filter,
         });
         TotalItemsCountEstimate totalItemsCountEstimate =
             OperationContextProxy.Current.FindHeader <TotalItemsCountEstimate>();
         return(totalItemsCountEstimate.Value);
     }
 }