/// <summary> /// Create Probematch message /// </summary> /// <param name="relatesTo">The probe message relates to</param> /// <param name="instanceId">The instanceId of the probe message</param> /// <param name="messageNumber">The messageNumber of probe message</param> /// <param name="matches">The probe matches</param> /// <returns>return probeMatch message</returns> public SoapEnvelope CreateProbeMatchMessage( string relatesTo, string instanceId, uint messageNumber, CustomProbeMatchType[] matches) { ProbeMatchType[] wsdiscoveryMatches = new ProbeMatchType[matches.Length]; XmlDocument doc = new XmlDocument(); for (int i = 0; i < matches.Length; i++) { wsdiscoveryMatches[i] = new ProbeMatchType(); wsdiscoveryMatches[i].EndpointReference = matches[i].EndpointReference; wsdiscoveryMatches[i].MetadataVersion = matches[i].MetadataVersion; wsdiscoveryMatches[i].Scopes = matches[i].Scopes; wsdiscoveryMatches[i].Types = matches[i].Types; wsdiscoveryMatches[i].XAddrs = matches[i].XAddrs; XmlElement peerDist = doc.CreateElement( "PeerDist", "PeerDistData", "http://schemas.microsoft.com/p2p/2007/09/PeerDistributionDiscovery"); XmlElement blockCount = doc.CreateElement( "PeerDist", "BlockCount", "http://schemas.microsoft.com/p2p/2007/09/PeerDistributionDiscovery"); blockCount.InnerText = matches[i].PeerDistData.BlockCount; peerDist.AppendChild(blockCount); wsdiscoveryMatches[i].Any = new XmlElement[] { peerDist }; } return this.service.CreateProbeMatchMessage(relatesTo, instanceId, messageNumber, wsdiscoveryMatches); }
/// <summary> /// Capture requirements for ProbeMatch structure /// </summary> /// <param name="probeMatch">ProbeMatch structure</param> private void CaptureProbeMatchRequirements(ProbeMatchType probeMatch) { this.CaptureAddressElementRequirements(probeMatch.EndpointReference.Address.Value); this.CaptureMetadataVersionRequirements(probeMatch.MetadataVersion); this.CaptureXAddrsElementRequirements(probeMatch.XAddrs); this.CaptureCustomizedAnyElementRequirements(probeMatch.Any); // Add debug info Site.Log.Add(LogEntryKind.Debug, "Types: {0}", probeMatch.Types); Site.CaptureRequirementIfIsNotNull( probeMatch.Types, 49, "[In Types] When [Types is] specified in the response, the value provides the Types that were found."); // Add debug info for (int i = 0; i < probeMatch.Scopes.Text.Length; i++) { Site.Log.Add(LogEntryKind.Debug, "Scopes[{0}]: {1}", i, probeMatch.Scopes.Text[i]); } Site.CaptureRequirementIfIsNotNull( probeMatch.Scopes.Text, 54, "[In Scopes] When sending the response, the value provides the list of scopes present in the cache."); // Since Scopes and Types are verified, the following requirement can be verified directly. Site.CaptureRequirement( 123, @"[In Receive Probe] The event processing involves checking the <Types> and <Scopes> elements to verify that the Probe was initiated by a peer."); }
/// <summary> /// Create a probe match message /// </summary> /// <param name="relatesTo">The URI of relates to</param> /// <param name="instanceId">Instance ID</param> /// <param name="messageNumber">Message number</param> /// <param name="matches">Probe match messages</param> /// <returns>The response message</returns> public SoapEnvelope CreateProbeMatchMessage(string relatesTo, string instanceId, uint messageNumber, ProbeMatchType[] matches) { WsdHeader header = new WsdHeader(); header.Action.Value = ProtocolStrings.ProbeMatchesAction; header.RelatesTo = new AttributedURI(); header.RelatesTo.Value = relatesTo; header.AppSequence = new AppSequenceType(); header.AppSequence.MessageNumber = 1; header.AppSequence.InstanceId = (uint)(this.serviceStartTime - this.baseTime).Seconds; header.To = new AttributedURI(); header.To.Value = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"; ProbeMatchOp match = new ProbeMatchOp(); match.ProbeMatches = new ProbeMatchesType(); match.ProbeMatches.ProbeMatch = matches; SoapEnvelope resp = new SoapEnvelope(SoapMessageVersion.Soap11Wsa10, header, match); return resp; }