Esempio n. 1
0
                private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int headerNameIndex = 0;

                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription header in message.Headers)
                    {
                        if (header.IsUnknownHeaderCollection)
                        {
                            info.SetUnknownHeaderDescription(header);
                        }
                        else if (headersMapping != null)
                        {
                            XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];

                            if (GeneratedXmlSerializers.IsInitialized)
                            {
                                // If GeneratedXmlSerializers has been initialized, we would use the
                                // mappings generated by .Net Native tools. In that case, the mappings
                                // we genrated at Runtime are just fake mapping instance which have
                                // no valid name/namespace. Therefore we cannot do the checks in the
                                // else block. Those checks should have been done during NET Native
                                // precompilation.
                                headerDescriptionTable.Add(header.Name, header.Namespace, header);
                            }
                            else
                            {
                                string headerName, headerNs;
                                headerName = memberMapping.XsdElementName;
                                headerNs   = memberMapping.Namespace;
                                if (headerName != header.Name)
                                {
                                    if (message.MessageType != null)
                                    {
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
                                    }
                                    else
                                    {
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
                                    }
                                }
                                if (headerNs != header.Namespace)
                                {
                                    if (message.MessageType != null)
                                    {
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
                                    }
                                    else
                                    {
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
                                    }
                                }

                                headerDescriptionTable.Add(headerName, headerNs, header);
                            }
                        }
                    }
                }
                private void CreateHeaderDescriptionTable(MessageDescription message, XmlSerializerOperationBehavior.Reflector.MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int num = 0;

                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription description in message.Headers)
                    {
                        if (description.IsUnknownHeaderCollection)
                        {
                            info.SetUnknownHeaderDescription(description);
                        }
                        else if (headersMapping != null)
                        {
                            string           typeName;
                            string           typeNamespace;
                            XmlMemberMapping mapping = headersMapping[num++];
                            if (this.IsEncoded)
                            {
                                typeName      = mapping.TypeName;
                                typeNamespace = mapping.TypeNamespace;
                            }
                            else
                            {
                                typeName      = mapping.XsdElementName;
                                typeNamespace = mapping.Namespace;
                            }
                            if (typeName != description.Name)
                            {
                                if (message.MessageType != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNameMismatchInMessageContract", new object[] { message.MessageType, description.MemberInfo.Name, description.Name, typeName })));
                                }
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNameMismatchInOperation", new object[] { this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, description.Name, typeName })));
                            }
                            if (typeNamespace != description.Namespace)
                            {
                                if (message.MessageType != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNamespaceMismatchInMessageContract", new object[] { message.MessageType, description.MemberInfo.Name, description.Namespace, typeNamespace })));
                                }
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNamespaceMismatchInOperation", new object[] { this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, description.Namespace, typeNamespace })));
                            }
                            headerDescriptionTable.Add(typeName, typeNamespace, description);
                        }
                    }
                }
Esempio n. 3
0
                private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int headerNameIndex = 0;

                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription header in message.Headers)
                    {
                        if (header.IsUnknownHeaderCollection)
                        {
                            info.SetUnknownHeaderDescription(header);
                        }
                        else if (headersMapping != null)
                        {
                            XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];
                            string           headerName, headerNs;
                            headerName = memberMapping.XsdElementName;
                            headerNs   = memberMapping.Namespace;
                            if (headerName != header.Name)
                            {
                                if (message.MessageType != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
                                }
                                else
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
                                }
                            }
                            if (headerNs != header.Namespace)
                            {
                                if (message.MessageType != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
                                }
                                else
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
                                }
                            }

                            headerDescriptionTable.Add(headerName, headerNs, header);
                        }
                    }
                }
 internal void SetHeaderDescriptionTable(OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable)
 {
     _headerDescriptionTable = headerDescriptionTable;
 }
                private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int headerNameIndex = 0;
                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription header in message.Headers)
                    {
                        if (header.IsUnknownHeaderCollection)
                            info.SetUnknownHeaderDescription(header);
                        else if (headersMapping != null)
                        {
                            XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];

                            if (GeneratedXmlSerializers.IsInitialized)
                            {
                                // If GeneratedXmlSerializers has been initialized, we would use the 
                                // mappings generated by .Net Native tools. In that case, the mappings
                                // we genrated at Runtime are just fake mapping instance which have
                                // no valid name/namespace. Therefore we cannot do the checks in the
                                // else block. Those checks should have been done during NET Native 
                                // precompilation.
                                headerDescriptionTable.Add(header.Name, header.Namespace, header);
                            }
                            else
                            {
                                string headerName, headerNs;
                                headerName = memberMapping.XsdElementName;
                                headerNs = memberMapping.Namespace;
                                if (headerName != header.Name)
                                {
                                    if (message.MessageType != null)
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
                                    else
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
                                }
                                if (headerNs != header.Namespace)
                                {
                                    if (message.MessageType != null)
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
                                    else
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
                                }

                                headerDescriptionTable.Add(headerName, headerNs, header);
                            }
                        }
                    }
                }
 private void CreateHeaderDescriptionTable(MessageDescription message, XmlSerializerOperationBehavior.Reflector.MessageInfo info, XmlMembersMapping headersMapping)
 {
     int num = 0;
     OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
     info.SetHeaderDescriptionTable(headerDescriptionTable);
     foreach (MessageHeaderDescription description in message.Headers)
     {
         if (description.IsUnknownHeaderCollection)
         {
             info.SetUnknownHeaderDescription(description);
         }
         else if (headersMapping != null)
         {
             string typeName;
             string typeNamespace;
             XmlMemberMapping mapping = headersMapping[num++];
             if (this.IsEncoded)
             {
                 typeName = mapping.TypeName;
                 typeNamespace = mapping.TypeNamespace;
             }
             else
             {
                 typeName = mapping.XsdElementName;
                 typeNamespace = mapping.Namespace;
             }
             if (typeName != description.Name)
             {
                 if (message.MessageType != null)
                 {
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNameMismatchInMessageContract", new object[] { message.MessageType, description.MemberInfo.Name, description.Name, typeName })));
                 }
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNameMismatchInOperation", new object[] { this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, description.Name, typeName })));
             }
             if (typeNamespace != description.Namespace)
             {
                 if (message.MessageType != null)
                 {
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNamespaceMismatchInMessageContract", new object[] { message.MessageType, description.MemberInfo.Name, description.Namespace, typeNamespace })));
                 }
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeaderNamespaceMismatchInOperation", new object[] { this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, description.Namespace, typeNamespace })));
             }
             headerDescriptionTable.Add(typeName, typeNamespace, description);
         }
     }
 }
 internal void SetHeaderDescriptionTable(OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable)
 {
     this.headerDescriptionTable = headerDescriptionTable;
 }
                private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int headerNameIndex = 0;
                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription header in message.Headers)
                    {
                        if (header.IsUnknownHeaderCollection)
                            info.SetUnknownHeaderDescription(header);
                        else if (headersMapping != null)
                        {
                            XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];
                            string headerName, headerNs;
                            if (IsEncoded)
                            {
                                headerName = memberMapping.TypeName;
                                headerNs = memberMapping.TypeNamespace;
                            }
                            else
                            {
                                headerName = memberMapping.XsdElementName;
                                headerNs = memberMapping.Namespace;
                            }
                            if (headerName != header.Name)
                            {
                                if (message.MessageType != null)
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
                                else
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
                            }
                            if (headerNs != header.Namespace)
                            {
                                if (message.MessageType != null)
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
                                else
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
                            }

                            headerDescriptionTable.Add(headerName, headerNs, header);
                        }
                    }
                }