예제 #1
0
 bool IEqualityComparer <MessageDescription> .Equals(MessageDescription x, MessageDescription y)
 {
     if (x.XsdTypeName != y.XsdTypeName)
     {
         return(false);
     }
     if (x.Headers.Count != y.Headers.Count)
     {
         return(false);
     }
     MessageHeaderDescription[] array = new MessageHeaderDescription[x.Headers.Count];
     x.Headers.CopyTo(array, 0);
     MessageHeaderDescription[] descriptionArray2 = new MessageHeaderDescription[y.Headers.Count];
     y.Headers.CopyTo(descriptionArray2, 0);
     if (x.Headers.Count > 1)
     {
         Array.Sort <MessagePartDescription>((MessagePartDescription[])array, MessagePartDescriptionComparer.Singleton);
         Array.Sort <MessagePartDescription>((MessagePartDescription[])descriptionArray2, MessagePartDescriptionComparer.Singleton);
     }
     for (int i = 0; i < array.Length; i++)
     {
         if (MessagePartDescriptionComparer.Singleton.Compare(array[i], descriptionArray2[i]) != 0)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
            bool IEqualityComparer <MessageDescription> .Equals(MessageDescription x, MessageDescription y)
            {
                if (x.XsdTypeName != y.XsdTypeName)
                {
                    return(false);
                }
                // compare headers
                if (x.Headers.Count != y.Headers.Count)
                {
                    return(false);
                }

                MessageHeaderDescription[] xHeaders = new MessageHeaderDescription[x.Headers.Count];
                x.Headers.CopyTo(xHeaders, 0);
                MessageHeaderDescription[] yHeaders = new MessageHeaderDescription[y.Headers.Count];
                y.Headers.CopyTo(yHeaders, 0);
                if (x.Headers.Count > 1)
                {
                    Array.Sort((MessagePartDescription[])xHeaders, MessagePartDescriptionComparer.Singleton);
                    Array.Sort((MessagePartDescription[])yHeaders, MessagePartDescriptionComparer.Singleton);
                }

                for (int i = 0; i < xHeaders.Length; i++)
                {
                    if (MessagePartDescriptionComparer.Singleton.Compare(xHeaders[i], yHeaders[i]) != 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }
예제 #3
0
 internal MessageHeaderDescription(MessageHeaderDescription other) : base(other)
 {
     this.MustUnderstand            = other.MustUnderstand;
     this.Relay                     = other.Relay;
     this.Actor                     = other.Actor;
     this.TypedHeader               = other.TypedHeader;
     this.IsUnknownHeaderCollection = other.IsUnknownHeaderCollection;
 }
 internal MessageHeaderDescription(MessageHeaderDescription other) : base(other)
 {
     this.MustUnderstand = other.MustUnderstand;
     this.Relay = other.Relay;
     this.Actor = other.Actor;
     this.TypedHeader = other.TypedHeader;
     this.IsUnknownHeaderCollection = other.IsUnknownHeaderCollection;
 }
예제 #5
0
            private void ExportMessageHeaderBinding(MessageHeaderDescription header, XmlQualifiedName messageName, bool isEncoded, MessageBinding messageBinding)
            {
                SoapHeaderBinding binding = SoapHelper.CreateSoapHeaderBinding(this.endpointContext, messageBinding);

                binding.Part    = string.IsNullOrEmpty(header.UniquePartName) ? header.Name : header.UniquePartName;
                binding.Message = messageName;
                binding.Use     = isEncoded ? SoapBindingUse.Encoded : SoapBindingUse.Literal;
                if (isEncoded)
                {
                    binding.Encoding = XmlSerializerOperationFormatter.GetEncoding(this.soapVersion);
                }
            }
 private void SetUnknownHeaderInDescription(MessageHeaderDescription header)
 {
     if (!this.IsEncoded && (header.AdditionalAttributesProvider != null))
     {
         XmlAttributes attributes = new XmlAttributes(header.AdditionalAttributesProvider);
         foreach (XmlAnyElementAttribute attribute in attributes.XmlAnyElements)
         {
             if (string.IsNullOrEmpty(attribute.Name))
             {
                 header.IsUnknownHeaderCollection = true;
             }
         }
     }
 }
예제 #7
0
 private void SetUnknownHeaderInDescription(MessageHeaderDescription header)
 {
     if (header.AdditionalAttributesProvider != null)
     {
         object[] attrs = header.AdditionalAttributesProvider.GetCustomAttributes(false);
         foreach (var attr in attrs)
         {
             if (attr is XmlAnyElementAttribute)
             {
                 if (String.IsNullOrEmpty(((XmlAnyElementAttribute)attr).Name))
                 {
                     header.IsUnknownHeaderCollection = true;
                 }
             }
         }
     }
 }
                private XmlMembersMapping LoadHeadersMapping(MessageDescription message, string mappingKey)
                {
                    int count = message.Headers.Count;

                    if (count == 0)
                    {
                        return(null);
                    }
                    if (this.IsEncoded)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxHeadersAreNotSupportedInEncoded", new object[] { message.MessageName })));
                    }
                    int num2 = 0;
                    int num3 = 0;

                    XmlReflectionMember[] sourceArray = new XmlReflectionMember[count];
                    for (int i = 0; i < count; i++)
                    {
                        MessageHeaderDescription part = message.Headers[i];
                        if (!part.IsUnknownHeaderCollection)
                        {
                            sourceArray[num3++] = XmlSerializerHelper.GetXmlReflectionMember(part, false, this.IsEncoded, false);
                        }
                        else
                        {
                            num2++;
                        }
                    }
                    if (num2 == count)
                    {
                        return(null);
                    }
                    if (num2 > 0)
                    {
                        XmlReflectionMember[] destinationArray = new XmlReflectionMember[count - num2];
                        Array.Copy(sourceArray, destinationArray, destinationArray.Length);
                        sourceArray = destinationArray;
                    }
                    return(this.ImportMembersMapping(this.ContractName, this.ContractNamespace, sourceArray, false, false, mappingKey));
                }
예제 #9
0
                private XmlMembersMapping LoadHeadersMapping(MessageDescription message, string mappingKey)
                {
                    int headerCount = message.Headers.Count;

                    if (headerCount == 0)
                    {
                        return(null);
                    }

                    int unknownHeaderCount = 0, headerIndex = 0;

                    XmlReflectionMember[] members = new XmlReflectionMember[headerCount];
                    for (int i = 0; i < headerCount; i++)
                    {
                        MessageHeaderDescription header = message.Headers[i];
                        if (!header.IsUnknownHeaderCollection)
                        {
                            members[headerIndex++] = XmlSerializerHelper.GetXmlReflectionMember(header, false /*isRpc*/, false /*isWrapped*/);
                        }
                        else
                        {
                            unknownHeaderCount++;
                        }
                    }

                    if (unknownHeaderCount == headerCount)
                    {
                        return(null);
                    }

                    if (unknownHeaderCount > 0)
                    {
                        XmlReflectionMember[] newMembers = new XmlReflectionMember[headerCount - unknownHeaderCount];
                        Array.Copy(members, newMembers, newMembers.Length);
                        members = newMembers;
                    }

                    return(ImportMembersMapping(ContractName, ContractNamespace, members, false /*isWrapped*/, false /*isRpc*/, mappingKey));
                }
 internal object GetContentAndSaveHeaderAttributes(object parameterValue, MessageHeaderDescription headerDescription)
 {
     bool flag;
     bool flag2;
     string str;
     if (parameterValue == null)
     {
         return null;
     }
     if (headerDescription.Multiple)
     {
         object[] objArray = (object[]) parameterValue;
         MessageHeader<object>[] headerArray = new MessageHeader<object>[objArray.Length];
         Array array = Array.CreateInstance(headerDescription.Type, objArray.Length);
         for (int i = 0; i < array.Length; i++)
         {
             array.SetValue(OperationFormatter.GetContentOfMessageHeaderOfT(headerDescription, objArray[i], out flag, out flag2, out str), i);
             headerArray[i] = new MessageHeader<object>(null, flag, str, flag2);
         }
         this.attributes[headerDescription.Index] = headerArray;
         return array;
     }
     object obj2 = OperationFormatter.GetContentOfMessageHeaderOfT(headerDescription, parameterValue, out flag, out flag2, out str);
     this.attributes[headerDescription.Index] = new MessageHeader<object>(null, flag, str, flag2);
     return obj2;
 }
            void ExportMessageHeaderBinding(MessageHeaderDescription header, XmlQualifiedName messageName, bool isEncoded, WsdlNS.MessageBinding messageBinding)
            {
#if DEBUG
                Fx.Assert(NamingHelper.IsValidNCName(messageName.Name), "Name value has to be a valid NCName.");
#endif
                WsdlNS.SoapHeaderBinding headerBinding = SoapHelper.CreateSoapHeaderBinding(endpointContext, messageBinding);
                headerBinding.Part = string.IsNullOrEmpty(header.UniquePartName) ? header.Name : header.UniquePartName;
                headerBinding.Message = messageName;
                headerBinding.Use = isEncoded ? WsdlNS.SoapBindingUse.Encoded : WsdlNS.SoapBindingUse.Literal;
                if (isEncoded)
                    headerBinding.Encoding = XmlSerializerOperationFormatter.GetEncoding(soapVersion);
            }
예제 #12
0
		MessageHeader CreateHeader (MessageHeaderDescription mh, object value)
		{
			return MessageHeader.CreateHeader (mh.Name, mh.Namespace, value, mh.MustUnderstand, mh.Actor, mh.Relay);
		}
 internal object CreateMessageHeader(MessageHeaderDescription headerDescription, object headerValue)
 {
     if (headerDescription.Multiple)
     {
         IList<MessageHeader<object>> messageHeaderOfTAttributes = (IList<MessageHeader<object>>)_attributes[headerDescription.Index];
         object[] messageHeaderOfTArray = (object[])Array.CreateInstance(TypedHeaderManager.GetMessageHeaderType(headerDescription.Type), messageHeaderOfTAttributes.Count);
         Array headerValues = (Array)headerValue;
         for (int i = 0; i < messageHeaderOfTArray.Length; i++)
         {
             MessageHeader<object> messageHeaderOfTAttribute = messageHeaderOfTAttributes[i];
             messageHeaderOfTArray[i] = TypedHeaderManager.Create(headerDescription.Type, headerValues.GetValue(i),
                                                           messageHeaderOfTAttribute.MustUnderstand, messageHeaderOfTAttribute.Relay, messageHeaderOfTAttribute.Actor);
         }
         return messageHeaderOfTArray;
     }
     else
     {
         MessageHeader<object> messageHeaderOfTAttribute = (MessageHeader<object>)_attributes[headerDescription.Index];
         return TypedHeaderManager.Create(headerDescription.Type, headerValue,
                                                       messageHeaderOfTAttribute.MustUnderstand, messageHeaderOfTAttribute.Relay, messageHeaderOfTAttribute.Actor);
     }
 }
            internal void GetHeaderAttributes(MessageHeaderDescription headerDescription, out bool mustUnderstand, out bool relay, out string actor)
            {
                MessageHeader<object> matchingMessageHeaderOfTAttribute = null;
                if (headerDescription.Multiple)
                {
                    MessageHeader<object>[] messageHeaderOfTAttributes = (MessageHeader<object>[])_attributes[headerDescription.Index];
                    for (int i = 0; i < messageHeaderOfTAttributes.Length; i++)
                    {
                        if (messageHeaderOfTAttributes[i] != null)
                        {
                            matchingMessageHeaderOfTAttribute = messageHeaderOfTAttributes[i];
                            messageHeaderOfTAttributes[i] = null;
                            break;
                        }
                    }
                    //assert(matchingMessageHeaderOfTAttribute != null);

                }
                else
                    matchingMessageHeaderOfTAttribute = (MessageHeader<object>)_attributes[headerDescription.Index];
                mustUnderstand = matchingMessageHeaderOfTAttribute.MustUnderstand;
                relay = matchingMessageHeaderOfTAttribute.Relay;
                actor = matchingMessageHeaderOfTAttribute.Actor;
            }
        private static void AddUnknownHeader(MessageHeaderDescription unknownHeaderDescription, ArrayList unknownHeaders, XmlDocument xmlDoc, XmlDictionaryWriter bufferWriter, MessageHeaderInfo header, XmlDictionaryReader headerReader)
        {
            object unknownHeader = xmlDoc.ReadNode(headerReader);
            if (bufferWriter != null)
                ((XmlElement)unknownHeader).WriteTo(bufferWriter);
            if (unknownHeader != null && unknownHeaderDescription.TypedHeader)
                unknownHeader = TypedHeaderManager.Create(unknownHeaderDescription.Type, unknownHeader, header.MustUnderstand, header.Relay, header.Actor);

            unknownHeaders.Add(unknownHeader);
        }
 internal void SetUnknownHeaderDescription(MessageHeaderDescription unknownHeaderDescription)
 {
     this.unknownHeaderDescription = unknownHeaderDescription;
 }
 private void SetUnknownHeaderInDescription(MessageHeaderDescription header)
 {
     if (this.IsEncoded) //XmlAnyElementAttribute does not apply
         return;
     if (header.AdditionalAttributesProvider != null)
     {
         XmlAttributes xmlAttributes = new XmlAttributes(header.AdditionalAttributesProvider);
         foreach (XmlAnyElementAttribute anyElement in xmlAttributes.XmlAnyElements)
         {
             if (String.IsNullOrEmpty(anyElement.Name))
             {
                 header.IsUnknownHeaderCollection = true;
             }
         }
     }
 }
 private object DeserializeHeaderContents(XmlDictionaryReader reader, MessageVersion version, MessageHeaderDescription headerDescription)
 {
     return this.serializerFactory.CreateSerializer(headerDescription.Type, headerDescription.Name, headerDescription.Namespace, this.knownTypes).ReadObject(reader);
 }
 private object DeserializeHeaderContents(XmlDictionaryReader reader, MessageDescription messageDescription, MessageHeaderDescription headerDescription)
 {
     bool isQueryable;
     Type dataContractType = DataContractSerializerOperationFormatter.GetSubstituteDataContractType(headerDescription.Type, out isQueryable);
     XmlObjectSerializer serializerLocal = _serializerFactory.CreateSerializer(dataContractType, headerDescription.Name, headerDescription.Namespace, _knownTypes);
     object val = serializerLocal.ReadObject(reader);
     if (isQueryable && val != null)
     {
         return Queryable.AsQueryable((IEnumerable)val);
     }
     return val;
 }
 private void ExportMessageHeaderBinding(MessageHeaderDescription header, XmlQualifiedName messageName, bool isEncoded, MessageBinding messageBinding)
 {
     SoapHeaderBinding binding = SoapHelper.CreateSoapHeaderBinding(this.endpointContext, messageBinding);
     binding.Part = string.IsNullOrEmpty(header.UniquePartName) ? header.Name : header.UniquePartName;
     binding.Message = messageName;
     binding.Use = isEncoded ? SoapBindingUse.Encoded : SoapBindingUse.Literal;
     if (isEncoded)
     {
         binding.Encoding = XmlSerializerOperationFormatter.GetEncoding(this.soapVersion);
     }
 }
 private void SetUnknownHeaderInDescription(MessageHeaderDescription header)
 {
     if (header.AdditionalAttributesProvider != null)
     {
         object[] attrs = header.AdditionalAttributesProvider.GetCustomAttributes(false);
         foreach (var attr in attrs)
         {
             if (attr is XmlAnyElementAttribute)
             {
                 if (String.IsNullOrEmpty(((XmlAnyElementAttribute)attr).Name))
                 {
                     header.IsUnknownHeaderCollection = true;
                 }
             }
         }
     }
 }
 internal void SetUnknownHeaderDescription(MessageHeaderDescription unknownHeaderDescription)
 {
     _unknownHeaderDescription = unknownHeaderDescription;
 }
 internal object CreateMessageHeader(MessageHeaderDescription headerDescription, object headerValue)
 {
     if (headerDescription.Multiple)
     {
         IList<MessageHeader<object>> list = (IList<MessageHeader<object>>) this.attributes[headerDescription.Index];
         object[] objArray = (object[]) Array.CreateInstance(TypedHeaderManager.GetMessageHeaderType(headerDescription.Type), list.Count);
         Array array = (Array) headerValue;
         for (int i = 0; i < objArray.Length; i++)
         {
             MessageHeader<object> header = list[i];
             objArray[i] = TypedHeaderManager.Create(headerDescription.Type, array.GetValue(i), header.MustUnderstand, header.Relay, header.Actor);
         }
         return objArray;
     }
     MessageHeader<object> header2 = (MessageHeader<object>) this.attributes[headerDescription.Index];
     return TypedHeaderManager.Create(headerDescription.Type, headerValue, header2.MustUnderstand, header2.Relay, header2.Actor);
 }
 internal object GetContentAndSaveHeaderAttributes(object parameterValue, MessageHeaderDescription headerDescription)
 {
     if (parameterValue == null)
         return null;
     bool mustUnderstand;
     bool relay;
     string actor;
     if (headerDescription.Multiple)
     {
         object[] messageHeaderOfTArray = (object[])parameterValue;
         MessageHeader<object>[] messageHeaderOfTAttributes = new MessageHeader<object>[messageHeaderOfTArray.Length];
         Array tArray = Array.CreateInstance(headerDescription.Type, messageHeaderOfTArray.Length);
         for (int i = 0; i < tArray.Length; i++)
         {
             tArray.SetValue(GetContentOfMessageHeaderOfT(headerDescription, messageHeaderOfTArray[i], out mustUnderstand, out relay, out actor), i);
             messageHeaderOfTAttributes[i] = new MessageHeader<object>(null, mustUnderstand, actor, relay);
         }
         _attributes[headerDescription.Index] = messageHeaderOfTAttributes;
         return tArray;
     }
     else
     {
         object content = GetContentOfMessageHeaderOfT(headerDescription, parameterValue, out mustUnderstand, out relay, out actor);
         _attributes[headerDescription.Index] = new MessageHeader<object>(null, mustUnderstand, actor, relay);
         return content;
     }
 }
예제 #25
0
		static void AddPartProtectionRequirements (List<XmlQualifiedName> enc,
			List<XmlQualifiedName> sig,
			MessageHeaderDescription pd,
			ChannelProtectionRequirements cp)
		{
			if (!pd.HasProtectionLevel)
				return; // no specific part indication
			switch (pd.ProtectionLevel) {
			case ProtectionLevel.EncryptAndSign:
				enc.Add (new XmlQualifiedName (pd.Name, pd.Namespace));
				goto case ProtectionLevel.Sign;
			case ProtectionLevel.Sign:
				sig.Add (new XmlQualifiedName (pd.Name, pd.Namespace));
				break;
			}
		}
 internal void SetHeaderAttributes(MessageHeaderDescription headerDescription, bool mustUnderstand, bool relay, string actor)
 {
     if (headerDescription.Multiple)
     {
         if (_attributes[headerDescription.Index] == null)
             _attributes[headerDescription.Index] = new List<MessageHeader<object>>();
         ((List<MessageHeader<object>>)_attributes[headerDescription.Index]).Add(new MessageHeader<object>(null, mustUnderstand, actor, relay));
     }
     else
         _attributes[headerDescription.Index] = new MessageHeader<object>(null, mustUnderstand, actor, relay);
 }
 private void SetUnknownHeaderInDescription(MessageHeaderDescription header)
 {
     if (!this.IsEncoded && (header.AdditionalAttributesProvider != null))
     {
         XmlAttributes attributes = new XmlAttributes(header.AdditionalAttributesProvider);
         foreach (XmlAnyElementAttribute attribute in attributes.XmlAnyElements)
         {
             if (string.IsNullOrEmpty(attribute.Name))
             {
                 header.IsUnknownHeaderCollection = true;
             }
         }
     }
 }
 private static void AddHeaderProtectionRequirements(MessageHeaderDescription header, MessagePartSpecification signedParts,
     MessagePartSpecification encryptedParts, ProtectionLevel defaultProtectionLevel)
 {
     ProtectionLevel p = header.HasProtectionLevel ? header.ProtectionLevel : defaultProtectionLevel;
     if (p != ProtectionLevel.None)
     {
         XmlQualifiedName headerName = new XmlQualifiedName(header.Name, header.Namespace);
         signedParts.HeaderTypes.Add(headerName);
         if (p == ProtectionLevel.EncryptAndSign)
             encryptedParts.HeaderTypes.Add(headerName);
     }
 }
 internal void GetHeaderAttributes(MessageHeaderDescription headerDescription, out bool mustUnderstand, out bool relay, out string actor)
 {
     MessageHeader<object> header = null;
     if (headerDescription.Multiple)
     {
         MessageHeader<object>[] headerArray = (MessageHeader<object>[]) this.attributes[headerDescription.Index];
         for (int i = 0; i < headerArray.Length; i++)
         {
             if (headerArray[i] != null)
             {
                 header = headerArray[i];
                 headerArray[i] = null;
                 break;
             }
         }
     }
     else
     {
         header = (MessageHeader<object>) this.attributes[headerDescription.Index];
     }
     mustUnderstand = header.MustUnderstand;
     relay = header.Relay;
     actor = header.Actor;
 }