/// <summary>
        /// Adds status to <paramref name="statusMessage"/> from <paramref name="exception"/>
        /// </summary>
        /// <param name="statusMessage">
        /// The status message.
        /// </param>
        /// <param name="exception">
        /// The exception.
        /// </param>
        public void AddStatus(StatusMessageType statusMessage, Exception exception)
        {
            // FUNC 2.1 Where is the status attribute?
            if (exception == null)
            {
                statusMessage.status = StatusTypeConstants.Success;
            }
            else
            {
                statusMessage.status = StatusTypeConstants.Failure;
                ErrorReport errorReport = ErrorReport.Build(exception);
                if (ObjectUtil.ValidCollection(errorReport.ErrorMessage))
                {
                    var statusMessageType = new Org.Sdmx.Resources.SdmxMl.Schemas.V21.Common.StatusMessageType();
                    statusMessage.MessageText.Add(statusMessageType);

                    foreach (string errors in errorReport.ErrorMessage)
                    {
                        var text = new TextType();
                        statusMessageType.Text.Add(text);
                        text.TypedValue = errors;
                    }
                }
            }
        }
        /// <summary>
        /// Adds submission result.
        /// </summary>
        /// <param name="returnType">
        /// The return type.
        /// </param>
        /// <param name="structureReference">
        /// The structure reference.
        /// </param>
        /// <param name="exception">
        /// The exception.
        /// </param>
        private void AddSubmissionResult(
            SubmitStructureResponseType returnType, IStructureReference structureReference, Exception exception)
        {
            var submissionResult = new SubmissionResultType();
            returnType.SubmissionResult.Add(submissionResult);
            var statusMessageType = new StatusMessageType();
            submissionResult.StatusMessage = statusMessageType;
            this.AddStatus(statusMessageType, exception);
            var submittedStructure = new SubmittedStructureType();
            submissionResult.SubmittedStructure = submittedStructure;
            var refType = new MaintainableReferenceType();
            submittedStructure.MaintainableObject = refType;
            if (ObjectUtil.ValidString(structureReference.MaintainableUrn))
            {
                refType.URN.Add(structureReference.MaintainableUrn);
            }
            else
            {
                var xref = new MaintainableRefType();
                refType.SetTypedRef(xref);
                IMaintainableRefObject maintainableReference = structureReference.MaintainableReference;
                string value = maintainableReference.AgencyId;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    xref.agencyID = maintainableReference.AgencyId;
                }

                string value1 = maintainableReference.MaintainableId;
                if (!string.IsNullOrWhiteSpace(value1))
                {
                    xref.agencyID = maintainableReference.MaintainableId;
                }

                string value2 = maintainableReference.Version;
                if (!string.IsNullOrWhiteSpace(value2))
                {
                    xref.agencyID = maintainableReference.Version;
                }
            }
        }
        /// <summary>
        /// Process the response.
        /// </summary>
        /// <param name="returnType">
        /// The return type.
        /// </param>
        /// <param name="registrationBean">
        /// The registration bean.
        /// </param>
        /// <param name="exception">
        /// The exception.
        /// </param>
        private void ProcessResponse(
            SubmitRegistrationsResponseType returnType, IRegistrationObject registrationBean, Exception exception)
        {
            var registrationStatusType = new RegistrationStatusType();
            returnType.RegistrationStatus.Add(registrationStatusType);
            var statusMessageType = new StatusMessageType();
            registrationStatusType.StatusMessage = statusMessageType;

            this.AddStatus(statusMessageType, exception);
            var registrationType = new RegistrationType();
            registrationStatusType.Registration = registrationType;
            registrationType.id = registrationBean.Id;
            if (registrationBean.DataSource != null)
            {
                IDataSource datasourceBean = registrationBean.DataSource;
                var datasourceType = new DataSourceType();
                registrationType.Datasource = datasourceType;

                if (datasourceBean.SimpleDatasource)
                {
                    Uri simpleDatasourceType = datasourceBean.DataUrl;
                    datasourceType.SimpleDataSource.Add(simpleDatasourceType);
                }
                else
                {
                    var queryableDatasource = new QueryableDataSourceType();
                    datasourceType.QueryableDataSource.Add(queryableDatasource);
                    queryableDatasource.isRESTDatasource = datasourceBean.RESTDatasource;
                    queryableDatasource.isWebServiceDatasource = datasourceBean.WebServiceDatasource;
                    queryableDatasource.DataURL = datasourceBean.DataUrl;
                    if (datasourceBean.WsdlUrl != null)
                    {
                        queryableDatasource.WSDLURL = datasourceBean.WsdlUrl;
                    }

                    if (datasourceBean.WadlUrl != null)
                    {
                        queryableDatasource.WADLURL = datasourceBean.WadlUrl;
                    }
                }
            }

            if (registrationBean.ProvisionAgreementRef != null)
            {
                var refType = new ProvisionAgreementReferenceType();
                registrationType.ProvisionAgreement = refType;
                refType.URN.Add(registrationBean.ProvisionAgreementRef.TargetUrn);
            }
        }