/// <summary>
        /// Capture requirements related with SOAP header in Probe message.
        /// </summary>
        /// <param name="header">SOAP header.</param>
        private void CaptureHeaderRequirements(WsdHeader header)
        {
            // Since the message parsed by stack layer properly, capture the requirement directly.
            Site.CaptureRequirement(
                171,
                @"[The schema definition of Header of Probe message is:]<s:Header ... >
                <a:Action ... >
                http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe
                </a:Action>
                <a:MessageID ... >xs:anyURI</a:MessageID>
                [<a:ReplyTo ... >endpoint-reference</a:ReplyTo>]?
                <a:To ... >xs:anyURI</a:To>
                ...
                </s:Header>");

            if (null != header.ReplyTo)
            {
                // Since the message parsed by stack layer properly, capture the requirement directly.
                Site.CaptureRequirement(
                    172,
                    "If [ReplyTo is] included in the header, it [ReplyTo] MUST be of type a:EndpointReferenceType [WS-Addressing].");
            }

            // Add debug info.
            Site.Log.Add(TestTools.LogEntryKind.Debug, "To: {0}", header.To.Value);
            bool isR173Verified = string.Equals(
                header.To.Value,
                "urn:schemas-xmlsoap-org:ws:2005:04:discovery",
                System.StringComparison.OrdinalIgnoreCase);

            Site.CaptureRequirementIfIsTrue(
                isR173Verified,
                173,
                "/s:Envelope/s:Header/a:To MUST be \"urn:schemas-xmlsoap-org:ws:2005:04:discovery\" [RFC 2141].");
        }
        /// <summary>
        /// Receive probe message.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="message">The probe message.</param>
        private void Server_ReceiveProbeMessage(IPEndPoint sender, SoapEnvelope message)
        {
            WsdHeader header = (WsdHeader)message.Header;
            ProbeType probe  = ((ProbeOp)message.Body).Probe;

            if (!this.isReceived && (!this.returned.Contains(header.MessageID.Value)))
            {
                this.isReceived = true;

                ProbeMsg probeMsg = new ProbeMsg(header.MessageID.Value, probe.Types, probe.Scopes.Text[0]);
                this.ReceiveProbeMessage(sender, probeMsg);
            }
        }
 /// <summary>
 /// Capture requirements related with SOAP header in ProbeMatch message.
 /// </summary>
 /// <param name="header">SOAP header.</param>
 private void CaptureHeaderRequirements(WsdHeader header)
 {
     // Since the message parsed by stack layer properly, capture the requirement directly.
     Site.CaptureRequirement(
         171,
         @"[The schema definition of Header of Probe message is:]<s:Header ... >
         <a:Action ... >
         http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe
         </a:Action>
         <a:MessageID ... >xs:anyURI</a:MessageID>
         [<a:ReplyTo ... >endpoint-reference</a:ReplyTo>]?
         <a:To ... >xs:anyURI</a:To>
         ...
         </s:Header>");
 }
        /// <summary>
        /// receive message handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="message">The soap envelope message</param>
        private void Server_ReceiveProbeMessage(IPEndPoint sender, SoapEnvelope message)
        {
            WsdHeader header = (WsdHeader)message.Header;
            ProbeType probe  = ((ProbeOp)message.Body).Probe;

            if (this.receive && (!this.returned.Contains(header.MessageID.Value)))
            {
                this.CaptureHeaderRequirements(header);
                this.CaptureProbeRequirements(probe);
                PccrdBothRoleCaptureCode.CaptureCommonRequirements(Site);
                PccrdBothRoleCaptureCode.CaptureTypesElementRequirements(probe.Types, Site);
                PccrdBothRoleCaptureCode.CaptureScopesElementRequirements(probe.Scopes, Site);

                ProbeMsg probeMsg = new ProbeMsg(header.MessageID.Value, probe.Types, probe.Scopes.Text[0]);
                this.ReceiveProbeMessage(sender, probeMsg);
            }
        }
        /// <summary>
        /// Receive the pccrd messages
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="message">The soap envelope message</param>
        private void Client_ReceivePccrdMessage(IPEndPoint sender, SoapEnvelope message)
        {
            Status status = new Status();

            status.ErrorCode = string.Empty;
            status.FaultType = FaultType.OK;

            WsdHeader header = (WsdHeader)message.Header;

            if (this.startReceiving && (!this.returned.Contains(header.MessageID.Value)))
            {
                this.returned.Add(header.MessageID.Value);
                ProbeMatchesType matches = ((ProbeMatchOp)message.Body).ProbeMatches;
                this.CaptureHeaderRequirements(header);
                this.CaptureProbeMatchesRequirements(matches);
                PccrdBothRoleCaptureCode.CaptureCommonRequirements(Site);
                foreach (ProbeMatchType match in matches.ProbeMatch)
                {
                    PccrdBothRoleCaptureCode.CaptureTypesElementRequirements(match.Types, Site);
                    PccrdBothRoleCaptureCode.CaptureScopesElementRequirements(match.Scopes, Site);
                }

                ProbeMatchMsg probeMatchMsg = new ProbeMatchMsg();
                probeMatchMsg.InstanceId    = header.AppSequence.InstanceId.ToString();
                probeMatchMsg.MessageNumber = header.AppSequence.MessageNumber;
                PeerProperties[] result = new PeerProperties[matches.ProbeMatch.Length];

                for (int i = 0; i < matches.ProbeMatch.Length; i++)
                {
                    result[i]                 = new PeerProperties();
                    result[i].Address         = matches.ProbeMatch[i].EndpointReference.Address.Value;
                    result[i].BlockCount      = matches.ProbeMatch[i].Any[0].InnerText;
                    result[i].MetadataVersion = matches.ProbeMatch[i].MetadataVersion;
                    result[i].Scopes          = matches.ProbeMatch[i].Scopes.Text[0];
                    result[i].Types           = matches.ProbeMatch[i].Types;
                    result[i].XAddrs          = matches.ProbeMatch[i].XAddrs;
                }

                probeMatchMsg.Matches = result;
                this.ReceiveProbeMatchMessage(status, probeMatchMsg);
            }
        }
Ejemplo n.º 6
0
        /// <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);
        }