Example #1
0
        private void runAssertions(SIFHeaderType header)
        {
            OperationContext context      = OperationContext.Current;
            MessageHeaders   headers      = context.IncomingMessageHeaders;
            UniqueId         contextMsgId = headers.MessageId;

            if (contextMsgId == null)
            {
                throw new FaultException("No WS-AddressingMsgId Specified");
            }
            Console.WriteLine("Received message with ID: {0}", contextMsgId);

            String action = headers.Action;

            if (action == null)
            {
                throw new FaultException("No WS-Addressing Action specified");
            }
            Console.WriteLine("   -Action: {0}", action);

            if (!action.StartsWith("http://www.sifassociation.org/contract/FlowControl-S11/2.x/"))
            {
                throw new FaultException("Action does not start with 'http://www.sifassociation.org/contract/FlowControl/2.x/'");
            }

            if (String.IsNullOrEmpty(header.SourceId))
            {
                throw new FaultException("SourceId is null");
            }

            Console.WriteLine("   -SourceId: {0}", header.SourceId);

            if (header.InfrastructureVersion != "2.5")
            {
                throw new FaultException("Infrastructure Version is " + header.InfrastructureVersion + " instead of '2.5'");
            }

            Console.WriteLine("   -InfraVer: {0}", header.InfrastructureVersion);

            if (header.Timestamp == null)
            {
                throw new FaultException("Missing timestamp, or incorrect timestamp");
            }
            DateTime timestamp = header.Timestamp;
            TimeSpan diff      = DateTime.Now - timestamp;

            if (diff.TotalDays > 30)
            {
                throw new FaultException("Timestamp: '" + timestamp + "' does not represent a recent date");
            }

            Console.WriteLine("   -Timestamp: {0}", header.Timestamp);
            if (String.IsNullOrEmpty(header.ZoneId))
            {
                throw new FaultException("ZoneId is null");
            }
            Console.WriteLine("   -ZoneId: {0}", header.ZoneId);
        }
Example #2
0
        private void runAssertions(SIFHeaderType header)
        {
            OperationContext context = OperationContext.Current;
            MessageHeaders headers = context.IncomingMessageHeaders;
            UniqueId contextMsgId = headers.MessageId;
            if (contextMsgId == null)
            {
                throw new FaultException("No WS-AddressingMsgId Specified");
            }
            Console.WriteLine("Received message with ID: {0}", contextMsgId);

            String action = headers.Action;
            if (action == null)
            {
                throw new FaultException("No WS-Addressing Action specified");
            }
            Console.WriteLine("   -Action: {0}", action);

            if (!action.StartsWith("http://www.sifassociation.org/contract/FlowControl-S11/2.x/"))
            {
                throw new FaultException("Action does not start with 'http://www.sifassociation.org/contract/FlowControl/2.x/'");
            }

            if (String.IsNullOrEmpty( header.SourceId))
            {
                throw new FaultException("SourceId is null");
            }

            Console.WriteLine("   -SourceId: {0}", header.SourceId);

            if (header.InfrastructureVersion != "2.5")
            {
                throw new FaultException("Infrastructure Version is " + header.InfrastructureVersion + " instead of '2.5'");
            }

            Console.WriteLine("   -InfraVer: {0}", header.InfrastructureVersion);

            if (header.Timestamp == null)
            {
                throw new FaultException("Missing timestamp, or incorrect timestamp");
            }
            DateTime timestamp = header.Timestamp;
            TimeSpan diff = DateTime.Now - timestamp;
            if (diff.TotalDays > 30)
            {
                throw new FaultException("Timestamp: '" + timestamp + "' does not represent a recent date");
            }

            Console.WriteLine("   -Timestamp: {0}", header.Timestamp);
            if (String.IsNullOrEmpty( header.ZoneId ))
            {
                throw new FaultException("ZoneId is null");
            }
            Console.WriteLine("   -ZoneId: {0}", header.ZoneId);
        }
Example #3
0
 private SIFHeaderType createHeader()
 {
     SIFHeaderType header = new SIFHeaderType();
     header.ZoneId = "foo:bar";
     header.DataModel = Statics.XMLNS_SIF_US_DATAMODEL;
     header.DataModelVersion = Statics.VERSION_US_DATAMODEL;
     header.SourceId = this.GetType().FullName;
     header.Timestamp = DateTime.Now;
     header.InfrastructureVersion = Statics.VERSION_INFRASTRUCTURE;
     return header;
 }
Example #4
0
        private PongResponse genericOKResponse()
        {
            SIFHeaderType header = createHeader();
            StatusType    status = new StatusType();

            status.Code = InfrastructureStatusCodeType.Item0;
            status.Desc = "Success";
            PongResponse resp = new PongResponse(header, status);

            return(resp);
        }
Example #5
0
        private SIFHeaderType createHeader()
        {
            SIFHeaderType header = new SIFHeaderType();

            header.ZoneId                = "foo:bar";
            header.DataModel             = Statics.XMLNS_SIF_US_DATAMODEL;
            header.DataModelVersion      = Statics.VERSION_US_DATAMODEL;
            header.SourceId              = this.GetType().FullName;
            header.Timestamp             = DateTime.Now;
            header.InfrastructureVersion = Statics.VERSION_INFRASTRUCTURE;
            return(header);
        }
Example #6
0
        private void runAssertions(SIFHeaderType header)
        {
            // TODO: Assert WS-Addressing headers

            //OperationContext context = OperationContext.Current;
            //MessageHeaders headers = context.IncomingMessageHeaders;
            //UniqueId contextMsgId = headers.MessageId;
            //if (contextMsgId == null)
            //{
            //    throw new FaultException("No WS-AddressingMsgId Specified");
            //}
            //Console.WriteLine("Received message with ID: {0}", contextMsgId);

            //String action = headers.Action;
            //if (action == null)
            //{
            //    throw new FaultException("No WS-Addressing Action specified");
            //}
            //Console.WriteLine("   -Action: {0}", action);

            //if (!action.StartsWith("http://www.sifassociation.org/contract/DataModel-S11/2.x/"))
            //{
            //    throw new FaultException("Action does not start with 'http://www.sifassociation.org/contract/DataModel-S11/2.x/'");
            //}

            Assert.IsNotNull(header, "SIFHeader was not returned");
            Assert.IsFalse(String.IsNullOrEmpty( header.SourceId), "SourceId is null" );
            Assert.AreNotEqual(header.SourceId, generateSourceId(), "SourceID is not valid");
            Assert.AreEqual( header.InfrastructureVersion, "2.5" );
            Assert.IsNotNull( header.Timestamp );
            DateTime timestamp = header.Timestamp;
            TimeSpan diff = DateTime.Now - timestamp;
            Assert.IsTrue(diff.TotalDays < 30, "Timestamp: '" + timestamp + "' does not represent a recent date");
            Assert.IsFalse( String.IsNullOrEmpty( header.ZoneId ), "ZoneId is null");
        }