Exemple #1
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;
 }
Exemple #2
0
        private EventStatus genericOKResponse()
        {
            SIFHeaderType header = createHeader();
            StatusType    status = new StatusType();

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

            return(resp);
        }
Exemple #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);
        }
Exemple #4
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/DataModel-S11/2.x/"))
            {
                throw new FaultException("Action does not start with 'http://www.sifassociation.org/contract/DataModel-S11/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);

            // Verify Data Model and Data Model Version
            if (!(header.DataModel == Statics.XMLNS_SIF_US_DATAMODEL))
            {
                throw new FaultException("Data Model does not match expected: " + header.DataModel);
            }

            if (!(header.DataModelVersion == Statics.VERSION_US_DATAMODEL))
            {
                throw new FaultException("Data Model Version incorrect:" + header.DataModelVersion);
            }
        }
Exemple #5
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/DataModel-S11/2.x/"))
            {
                throw new FaultException("Action does not start with 'http://www.sifassociation.org/contract/DataModel-S11/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);


            // Verify Data Model and Data Model Version
            if (!(header.DataModel == Statics.XMLNS_SIF_US_DATAMODEL))
            {
                throw new FaultException("Data Model does not match expected: " + header.DataModel);
            }

            if (!(header.DataModelVersion == Statics.VERSION_US_DATAMODEL))
            {
                throw new FaultException("Data Model Version incorrect:" + header.DataModelVersion);
            }
        }
Exemple #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");
        }