Example #1
0
 /// <summary>
 /// Default message
 /// </summary>
 /// <returns></returns>
 public MARC.Everest.RMIM.CA.R020402.Interactions.MCCI_IN000002CA Anything(IGraphable request)
 {
     return(new MARC.Everest.RMIM.CA.R020402.Interactions.MCCI_IN000002CA(
                Guid.NewGuid(),
                DateTime.Now,
                ResponseMode.Immediate,
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Production,
                AcknowledgementCondition.Never,
                new Receiver(
                    new TEL()
     {
         NullFlavor = NullFlavor.NoInformation
     },
                    new Device2(
                        new II()
     {
         NullFlavor = NullFlavor.NoInformation
     }
                        )
                    ),
                new Sender(
                    new TEL(OperationContext.Current.Channel.LocalAddress.Uri.ToString()),
                    new Device1(
                        new II("1.2.3.4", "1234"),
                        "Sample Service",
                        "A sample service",
                        null,
                        "Mohawk College of Applied Arts and Technology",
                        "Everest"
                        )
                    ),
                new Acknowledgement(
                    AcknowledgementType.ApplicationAcknowledgementAccept,
                    new TargetMessage()
     {
         NullFlavor = NullFlavor.NoInformation
     },
                    new AcknowledgementDetail(
                        AcknowledgementDetailType.Information,
                        AcknowledgementDetailCode.InternalSystemError,
                        String.Format("You just used the Everest Serializer! Received a '{0}'", request.GetType().Name),
                        null
                        )
                    )
                ));
 }
 /// <summary>
 /// Returns true if the client registry is available. This
 /// is done by sending an unsupported message to the CR,
 /// if the CR responds with anything then it is up, otherwise
 /// it is unavailable
 /// </summary>
 public bool IsCrAvailable(WcfClientConnector connector)
 {
     try
     {
         return(SendReceive(connector, new MCCI_IN000002CA(
                                Guid.NewGuid(),
                                DateTime.Now,
                                ResponseMode.Immediate,
                                MCCI_IN000002CA.GetInteractionId(),
                                MCCI_IN000002CA.GetProfileId(),
                                ProcessingID.Debugging,
                                AcknowledgementCondition.Always,
                                new MARC.Everest.RMIM.CA.R020402.MCCI_MT002200CA.Receiver(),
                                new MARC.Everest.RMIM.CA.R020402.MCCI_MT002200CA.Sender(),
                                null
                                )) != null);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #3
0
        public void WI1086_VerifyBugReflectTest()
        {
            // Load the XmlInstance into a string reader
            StringReader   sr = new StringReader(this.m_xmlInstance);
            XmlStateReader xr = new XmlStateReader(XmlReader.Create(sr));

            XmlIts1Formatter formatter = new XmlIts1Formatter();

            formatter.ValidateConformance = false;
            formatter.Settings            = SettingsType.DefaultUniprocessor;
            formatter.GraphAides.Add(new DatatypeFormatter()
            {
                CompatibilityMode = DatatypeFormatterCompatibilityMode.Canadian
            });

            try
            {
                MCCI_IN000002CA instance = formatter.Parse(xr, typeof(MCCI_IN000002CA)).Structure as MCCI_IN000002CA;
                if (instance == null)
                {
                    throw new InvalidOperationException("Invalid test data");
                }

                // Test 1, /receiver should be null (xsi:nil = true)
                Assert.IsNull(instance.Receiver, "Receiver");

                // Test 2, /sender should also be null (xsi:nil = true)
                Assert.IsNull(instance.Sender, "Sender");

                // Test 3, /acknowledgement should not be null and should have a null flavor (a notification should be notified though)
                Assert.IsNotNull(instance.Acknowledgement);
                Assert.AreEqual((NullFlavor)instance.Acknowledgement.NullFlavor.Code, NullFlavor.Unavailable);
            }
            finally
            {
                formatter.Dispose();
            }
        }
Example #4
0
        /// <summary>
        /// Create a domain identifier list
        /// </summary>
        //internal static List<DomainIdentifier> CreateDomainIdentifierList(List<MARC.Everest.RMIM.CA.R020403.REPC_MT500006CA.RecordId> list)
        //{
        //    List<DomainIdentifier> retVal = new List<DomainIdentifier>();
        //    foreach (var recId in list)
        //        retVal.Add(new DomainIdentifier()
        //        {
        //            Domain = recId.Value.Root,
        //            Identifier = recId.Value.Extension
        //        });
        //    return retVal;
        //}

        /// <summary>
        /// Validates common transport wrapper flags
        /// </summary>
        public static void ValidateTransportWrapper(IInteraction interaction, ISystemConfigurationService config, List <IResultDetail> dtls)
        {
            // Check the response mode code
            string rspMode  = Util.ToWireFormat((interaction as IImplementsResponseModeCode <ResponseMode>).ResponseModeCode);
            string procMode = Util.ToWireFormat((interaction as IImplementsProcessingCode <ProcessingID>).ProcessingCode);

            var profile = interaction as IImplementsProfileId;

            // Check response mode
            if (rspMode != "I")
            {
                dtls.Add(new UnsupportedResponseModeResultDetail(rspMode));
            }
            //// Check processing id
            //if (procMode != "P" && procMode != "D")
            //    dtls.Add(new UnsupportedProcessingModeResultDetail(procMode));

            // Check version identifier
            if (!interaction.VersionCode.CodeValue.Equals("V3-2008N"))
            {
                dtls.Add(new UnsupportedVersionResultDetail(String.Format("Version '{0}' is not supported by this endpoint", interaction.VersionCode)));
            }
            else if (profile == null || profile.ProfileId.Count(o => II.Comparator(o, MCCI_IN000002CA.GetProfileId()[0]) == 0) == 0)
            {
                dtls.Add(new UnsupportedVersionResultDetail(String.Format("Supplied profile identifier does not match any profile identifier this endpoint can reliably process")));
            }


            Sender sndr = interaction.GetType().GetProperty("Sender").GetValue(interaction, null) as Sender;

            if (sndr == null || sndr.NullFlavor != null || sndr.Device == null || sndr.Device.NullFlavor != null || sndr.Device.Id == null || sndr.Device.Id.IsNull)
            {
                dtls.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Sender information is missing from message", null));
            }
            else
            {
                var sndrId = new DomainIdentifier()
                {
                    Domain = sndr.Device.Id.Root, Identifier = sndr.Device.Id.Extension
                };
                if (!config.IsRegisteredDevice(sndrId))
                {
                    dtls.Add(new UnrecognizedSenderResultDetail(sndrId));
                }
            }
        }
Example #5
0
        /// <summary>
        /// Handles a received message
        /// </summary>
        public MARC.Everest.Interfaces.IGraphable HandleMessageReceived(object sender, UnsolicitedDataEventArgs e, MARC.Everest.Connectors.IReceiveResult receivedMessage)
        {
            // audit the error
            IAuditorService auditor = Context.GetService(typeof(IAuditorService)) as IAuditorService;
            AuditData       ad      = new AuditData(
                DateTime.Now, ActionType.Execute, OutcomeIndicator.EpicFail, EventIdentifierType.ApplicationActivity, new CodeValue(String.Format("{0}", receivedMessage.Structure))
                );

            ad.Actors.AddRange(new List <AuditActorData>(10)
            {
                new AuditActorData()
                {
                    NetworkAccessPointId = e.ReceiveEndpoint.ToString(), NetworkAccessPointType = NetworkAccessPointType.IPAddress, UserIsRequestor = false
                },
                new AuditActorData()
                {
                    NetworkAccessPointType = NetworkAccessPointType.MachineName, NetworkAccessPointId = Environment.MachineName, UserIsRequestor = false
                }
            }
                               );
            ad.AuditableObjects.Add(new AuditableObject()
            {
                IDTypeCode = AuditableObjectIdType.ReportNumber, LifecycleType = AuditableObjectLifecycle.Verification, ObjectId = (receivedMessage.Structure as IIdentifiable).Id.Root, Role = AuditableObjectRole.Subscriber, Type = AuditableObjectType.SystemObject
            });
            if (auditor != null)
            {
                auditor.SendAudit(ad);
            }

            IInteraction solicitation = receivedMessage.Structure as IInteraction;

            // get the configuration
            ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;

            // construct a generic response
            MCCI_IN000002CA response = new MCCI_IN000002CA(
                Guid.NewGuid(),
                DateTime.Now,
                new CV <ResponseMode>(ResponseMode.Immediate),
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Debugging,
                AcknowledgementCondition.Never,
                null,
                MessageUtil.CreateSender(e.ReceiveEndpoint, configService),
                new Acknowledgement(
                    AcknowledgementType.ApplicationAcknowledgementReject,
                    new TargetMessage(
                        (receivedMessage.Structure as IIdentifiable).Id
                        )
                    )
                );

            // Add a detail
            if (solicitation.InteractionId != null && solicitation.InteractionId.Extension != receivedMessage.Structure.GetType().Name)
            {
                response.Acknowledgement.AcknowledgementDetail.Add(
                    new AcknowledgementDetail(
                        AcknowledgementDetailType.Error,
                        Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.ValueDoesNotMatchFixedValue),
                        String.Format("Interaction ID '{0}' not supported for message type '{1}'", solicitation.InteractionId.Extension, receivedMessage.Structure.GetType().Name),
                        null));
            }
            else
            {
                response.Acknowledgement.AcknowledgementDetail.Add(
                    new AcknowledgementDetail(
                        AcknowledgementDetailType.Error,
                        Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedInteraction),
                        "Cannot process this interaction",
                        null)
                    );
            }

            // Validation detils
            response.Acknowledgement.AcknowledgementDetail.AddRange(MessageUtil.CreateGenAckDetails(receivedMessage.Details));

            // Populate the receiver
            Sender   originalSolicitor = solicitation.GetType().GetProperty("Sender").GetValue(solicitation, null) as Sender;
            Receiver receiver          = MessageUtil.CreateReceiver(originalSolicitor);

            response.Receiver = receiver;

            return(response);
        }
Example #6
0
        // Delegate handles the message available event
        static void connector_MessageAvailable(object sender,
                                               UnsolicitedDataEventArgs e)
        {
            // Cast connector
            WcfServerConnector connector = sender as WcfServerConnector;

            connector.InvalidResponse += new
                                         EventHandler <MessageEventArgs>(connector_InvalidResponse);
            // Receive the structure
            WcfReceiveResult rcvResult = connector.Receive() as WcfReceiveResult;

            if (rcvResult.Structure != null)
            {
                Console.WriteLine(rcvResult.Structure.GetType().Name);
            }

            // Prepare acknowledgement structure
            Acknowledgement acknowledgement = new Acknowledgement();

            // Assign the correlation
            acknowledgement.TargetMessage = new TargetMessage(
                (rcvResult.Structure as IIdentifiable).Id
                );

            // Determine the deserialization outcome
            if (rcvResult.Code != ResultCode.Accepted &&
                rcvResult.Code != ResultCode.AcceptedNonConformant)
            {
                // There were problems parsing the request message
                acknowledgement.TypeCode =
                    AcknowledgementType.AcceptAcknowledgementCommitError;
            }
            else
            {
                // Message is all good
                acknowledgement.TypeCode =
                    AcknowledgementType.AcceptAcknowledgementCommitAccept;
            }

            // Append all details
            foreach (IResultDetail dtl in rcvResult.Details)
            {
                AcknowledgementDetail detail = new AcknowledgementDetail(
                    AcknowledgementDetailType.Information,
                    AcknowledgementDetailCode.SyntaxError,
                    dtl.Message,
                    new SET <ST>((ST)dtl.Location)
                    );
                acknowledgement.AcknowledgementDetail.Add(detail);
            }

            // Create a response
            MCCI_IN000002CA response = new MCCI_IN000002CA(
                new II(Guid.NewGuid()),
                DateTime.Now,
                ResponseMode.Immediate,
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Production,
                AcknowledgementCondition.Never,
                new Receiver(
                    new Device2(
                        new II()
                        )
                    ),
                new Sender(
                    new
                    Device1(
                        new II("1.1.1.1.1")
                        )
                    ),
                acknowledgement
                );

            // Send the result
            connector.Send(response, rcvResult);
        }
Example #7
0
        // Delegate handles the message available event
        static void connector_MessageAvailable(object sender,
                 UnsolicitedDataEventArgs e)
        {
            // Cast connector
            WcfServerConnector connector = sender as WcfServerConnector;
            connector.InvalidResponse += new
                EventHandler<MessageEventArgs>(connector_InvalidResponse);
            // Receive the structure
            WcfReceiveResult rcvResult = connector.Receive() as WcfReceiveResult;

            if (rcvResult.Structure != null)
                Console.WriteLine(rcvResult.Structure.GetType().Name);

            // Prepare acknowledgement structure
            Acknowledgement acknowledgement = new Acknowledgement();

            // Assign the correlation
            acknowledgement.TargetMessage = new TargetMessage(
                     (rcvResult.Structure as IIdentifiable).Id
            );

            // Determine the deserialization outcome
            if (rcvResult.Code != ResultCode.Accepted &&
                rcvResult.Code != ResultCode.AcceptedNonConformant)
                // There were problems parsing the request message
                acknowledgement.TypeCode =
                    AcknowledgementType.AcceptAcknowledgementCommitError;
            else
                // Message is all good
                acknowledgement.TypeCode =
                   AcknowledgementType.AcceptAcknowledgementCommitAccept;

            // Append all details
            foreach (IResultDetail dtl in rcvResult.Details)
            {
                AcknowledgementDetail detail = new AcknowledgementDetail(
                        AcknowledgementDetailType.Information,
                        AcknowledgementDetailCode.SyntaxError,
                        dtl.Message, 
                        new SET<ST>((ST)dtl.Location)
                        );
                acknowledgement.AcknowledgementDetail.Add(detail);
            }

            // Create a response
            MCCI_IN000002CA response = new MCCI_IN000002CA(
                new II(Guid.NewGuid()),
                DateTime.Now,
                ResponseMode.Immediate,
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Production,
                AcknowledgementCondition.Never,
                new Receiver(
                    new Device2(
                        new II()
                 )
                ),
                new Sender(
                 new
                  Device1(
                        new II("1.1.1.1.1")
                 )
                ),
                acknowledgement
            );

            // Send the result
            connector.Send(response, rcvResult);
        }