internal void EnsureMessageInfos()
 {
     if (this.request == null)
     {
         foreach (System.Type type in this.Operation.KnownTypes)
         {
             if (type == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxKnownTypeNull", new object[] { this.Operation.Name })));
             }
             this.parent.importer.IncludeType(type, this.IsEncoded);
         }
         this.request = this.CreateMessageInfo(this.Operation.Messages[0], ":Request");
         if (((this.request != null) && this.IsRpc) && (this.Operation.IsValidateRpcWrapperName && (this.request.BodyMapping.XsdElementName != this.Operation.Name)))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxRpcMessageBodyPartNameInvalid", new object[] { this.Operation.Name, this.Operation.Messages[0].MessageName, this.request.BodyMapping.XsdElementName, this.Operation.Name })));
         }
         if (!this.IsOneWay)
         {
             this.reply = this.CreateMessageInfo(this.Operation.Messages[1], ":Response");
             System.ServiceModel.Description.XmlName bodyWrapperResponseName = TypeLoader.GetBodyWrapperResponseName(this.Operation.Name);
             if (((this.reply != null) && this.IsRpc) && (this.Operation.IsValidateRpcWrapperName && (this.reply.BodyMapping.XsdElementName != bodyWrapperResponseName.EncodedName)))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxRpcMessageBodyPartNameInvalid", new object[] { this.Operation.Name, this.Operation.Messages[1].MessageName, this.reply.BodyMapping.XsdElementName, bodyWrapperResponseName.EncodedName })));
             }
         }
         if (this.Attribute.SupportFaults)
         {
             this.GenerateXmlSerializerFaultContractInfos();
         }
     }
 }
                private XmlSerializerOperationBehavior.Reflector.MessageInfo CreateMessageInfo(MessageDescription message, string key)
                {
                    MessagePartDescriptionCollection descriptions;

                    if (message.IsUntypedMessage)
                    {
                        return(null);
                    }
                    XmlSerializerOperationBehavior.Reflector.MessageInfo info = new XmlSerializerOperationBehavior.Reflector.MessageInfo();
                    if (message.IsTypedMessage)
                    {
                        key = string.Concat(new object[] { message.MessageType.FullName, ":", this.IsEncoded, ":", this.IsRpc });
                    }
                    XmlMembersMapping mapping = this.LoadHeadersMapping(message, key + ":Headers");

                    info.SetHeaders(this.parent.generation.AddSerializer(mapping));
                    info.SetBody(this.parent.generation.AddSerializer(this.LoadBodyMapping(message, key, out descriptions)), descriptions);
                    this.CreateHeaderDescriptionTable(message, info, mapping);
                    return(info);
                }
 internal void EnsureMessageInfos()
 {
     if (this.request == null)
     {
         foreach (System.Type type in this.Operation.KnownTypes)
         {
             if (type == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxKnownTypeNull", new object[] { this.Operation.Name })));
             }
             this.parent.importer.IncludeType(type, this.IsEncoded);
         }
         this.request = this.CreateMessageInfo(this.Operation.Messages[0], ":Request");
         if (((this.request != null) && this.IsRpc) && (this.Operation.IsValidateRpcWrapperName && (this.request.BodyMapping.XsdElementName != this.Operation.Name)))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxRpcMessageBodyPartNameInvalid", new object[] { this.Operation.Name, this.Operation.Messages[0].MessageName, this.request.BodyMapping.XsdElementName, this.Operation.Name })));
         }
         if (!this.IsOneWay)
         {
             this.reply = this.CreateMessageInfo(this.Operation.Messages[1], ":Response");
             System.ServiceModel.Description.XmlName bodyWrapperResponseName = TypeLoader.GetBodyWrapperResponseName(this.Operation.Name);
             if (((this.reply != null) && this.IsRpc) && (this.Operation.IsValidateRpcWrapperName && (this.reply.BodyMapping.XsdElementName != bodyWrapperResponseName.EncodedName)))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxRpcMessageBodyPartNameInvalid", new object[] { this.Operation.Name, this.Operation.Messages[1].MessageName, this.reply.BodyMapping.XsdElementName, bodyWrapperResponseName.EncodedName })));
             }
         }
         if (this.Attribute.SupportFaults)
         {
             this.GenerateXmlSerializerFaultContractInfos();
         }
     }
 }
 private XmlSerializerOperationBehavior.Reflector.MessageInfo CreateMessageInfo(MessageDescription message, string key)
 {
     MessagePartDescriptionCollection descriptions;
     if (message.IsUntypedMessage)
     {
         return null;
     }
     XmlSerializerOperationBehavior.Reflector.MessageInfo info = new XmlSerializerOperationBehavior.Reflector.MessageInfo();
     if (message.IsTypedMessage)
     {
         key = string.Concat(new object[] { message.MessageType.FullName, ":", this.IsEncoded, ":", this.IsRpc });
     }
     XmlMembersMapping mapping = this.LoadHeadersMapping(message, key + ":Headers");
     info.SetHeaders(this.parent.generation.AddSerializer(mapping));
     info.SetBody(this.parent.generation.AddSerializer(this.LoadBodyMapping(message, key, out descriptions)), descriptions);
     this.CreateHeaderDescriptionTable(message, info, mapping);
     return info;
 }
                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);
                        }
                    }
                }