public CustomPolicyConversionContext (WS.Binding binding, ServiceEndpoint endpoint)
			: base (endpoint)
		{
			this.binding = binding;
			assertions = new PolicyAssertionCollection ();
			binding_elements = ((CustomBinding)endpoint.Binding).Elements;
		}
        internal WsdlContractConversionContext(ContractDescription contract, WsdlNS.PortType wsdlPortType)
        {

            this.contract = contract;
            this.wsdlPortType = wsdlPortType;

            this.wsdlOperations = new Dictionary<OperationDescription, WsdlNS.Operation>();
            this.operationDescriptions = new Dictionary<WsdlNS.Operation, OperationDescription>();
            this.wsdlOperationMessages = new Dictionary<MessageDescription, WsdlNS.OperationMessage>();
            this.messageDescriptions = new Dictionary<WsdlNS.OperationMessage, MessageDescription>();
            this.wsdlOperationFaults = new Dictionary<FaultDescription, WsdlNS.OperationFault>();
            this.faultDescriptions = new Dictionary<WsdlNS.OperationFault, FaultDescription>();
            this.operationBindings = new Dictionary<WsdlNS.Operation, Collection<WsdlNS.OperationBinding>>();
        }
        internal WsdlEndpointConversionContext(WsdlEndpointConversionContext bindingContext, ServiceEndpoint endpoint, WsdlNS.Port wsdlport)
        {

            this.endpoint = endpoint;
            this.wsdlBinding = bindingContext.WsdlBinding;
            this.wsdlPort = wsdlport;
            this.contractContext = bindingContext.contractContext;

            this.wsdlOperationBindings = bindingContext.wsdlOperationBindings;
            this.operationDescriptionBindings = bindingContext.operationDescriptionBindings;
            this.wsdlMessageBindings = bindingContext.wsdlMessageBindings;
            this.messageDescriptionBindings = bindingContext.messageDescriptionBindings;
            this.wsdlFaultBindings = bindingContext.wsdlFaultBindings;
            this.faultDescriptionBindings = bindingContext.faultDescriptionBindings;
        }
        internal WsdlEndpointConversionContext(WsdlContractConversionContext contractContext, ServiceEndpoint endpoint, WsdlNS.Binding wsdlBinding, WsdlNS.Port wsdlport)
        {

            this.endpoint = endpoint;
            this.wsdlBinding = wsdlBinding;
            this.wsdlPort = wsdlport;
            this.contractContext = contractContext;

            this.wsdlOperationBindings = new Dictionary<OperationDescription, WsdlNS.OperationBinding>();
            this.operationDescriptionBindings = new Dictionary<WsdlNS.OperationBinding, OperationDescription>();
            this.wsdlMessageBindings = new Dictionary<MessageDescription, WsdlNS.MessageBinding>();
            this.messageDescriptionBindings = new Dictionary<WsdlNS.MessageBinding, MessageDescription>();
            this.wsdlFaultBindings = new Dictionary<FaultDescription, WsdlNS.FaultBinding>();
            this.faultDescriptionBindings = new Dictionary<WsdlNS.FaultBinding, FaultDescription>();
        }
 static bool ContainsHttpBindingExtension(WsdlNS.Binding wsdlBinding)
 {
     //avoiding using wsdlBinding.Extensions.Find(typeof(WsdlNS.HttpBinding)) so the extension won't be marked as handled
     foreach (object extension in wsdlBinding.Extensions)
     {
         if (extension is WsdlNS.HttpBinding)
         {
             string httpVerb = ((WsdlNS.HttpBinding)extension).Verb;
             if (httpVerb.Equals("GET", StringComparison.OrdinalIgnoreCase) || httpVerb.Equals("POST", StringComparison.OrdinalIgnoreCase))
             {
                 return true;
             }
         }
     }
     return false;
 }
 public void BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, Xml.Schema.XmlSchemaSet xmlSchemas, ICollection<Xml.XmlElement> policy)
 {
     foreach (WsdlNS.ServiceDescription wsdl in wsdlDocuments)
     {
         if (wsdl != null)
         {
             foreach (WsdlNS.Binding wsdlBinding in wsdl.Bindings)
             {
                 if (wsdlBinding != null && wsdlBinding.Extensions != null)
                 {
                     WsdlNS.SoapBinding soapBinding = (WsdlNS.SoapBinding)wsdlBinding.Extensions.Find(typeof(WsdlNS.SoapBinding));
                     if (soapBinding != null)
                     {
                         string transportUri = soapBinding.Transport;
                         if (!string.IsNullOrEmpty(transportUri) && transportUri.Equals(UdpConstants.WsdlSoapUdpTransportUri, StringComparison.Ordinal))
                         {
                             WsdlImporter.SoapInPolicyWorkaroundHelper.InsertAdHocPolicy(wsdlBinding, soapBinding.Transport, this.udpTransportUriKey);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
		static void TestSoapBody (WS.SoapBodyBinding soap, bool soap12, TestLabel label)
		{
			label.EnterScope ("soap-body");
			var type = soap12 ? typeof (WS.Soap12BodyBinding) : typeof (WS.SoapBodyBinding);
			Assert.That (soap.GetType (), Is.EqualTo (type), label.Get ());
			Assert.That (soap.Encoding, Is.Empty, label.Get ());
			Assert.That (soap.Namespace, Is.Empty, label.Get ());
			Assert.That (soap.Parts, Is.Null, label.Get ());
			Assert.That (soap.Use, Is.EqualTo (WS.SoapBindingUse.Literal), label.Get ());
			label.LeaveScope ();
		}
Exemplo n.º 8
0
		static void TestSoap (WS.SoapOperationBinding soap, bool soap12, TestLabel label)
		{
			label.EnterScope ("soap");
			var type = soap12 ? typeof (WS.Soap12OperationBinding) : typeof (WS.SoapOperationBinding);
			Assert.That (soap.GetType (), Is.EqualTo (type), label.Get ());
			Assert.That (soap.Style, Is.EqualTo (WS.SoapBindingStyle.Document), label.Get ());
			Assert.That (soap.SoapAction, Is.EqualTo ("http://tempuri.org/IMyContract/Hello"), label.Get ());
			Assert.That (soap.Required, Is.False, label.Get ());
			label.LeaveScope ();
		}
Exemplo n.º 9
0
		public static PolicyAssertionCollection AssertPolicy (
			WS.Binding binding, TestLabel label)
		{
			label.EnterScope ("FindPolicy");
			XmlElement policy = null;
		
			foreach (var extension in binding.Extensions) {
				var xml = extension as XmlElement;
				if (xml == null)
					continue;
				Assert.That (policy, Is.Null, label.Get ());
				policy = xml;
			}
			Assert.That (policy, Is.Not.Null, label.Get ());
			try {
				return AssertPolicy (binding.ServiceDescription, policy, label);
			} finally {
				label.LeaveScope ();
			}
		}
Exemplo n.º 10
0
		void AddToMetadataIfNotNull(WSDescription.ServiceDescription serviceDescription)
		{
			if (serviceDescription != null) {
				AddMetadataSection(MetadataSection.ServiceDescriptionDialect, serviceDescription);
			}
		}
            void ExportMessageBodyBinding(MessageDescription messageDescription, bool isRpc, bool isEncoded, WsdlNS.MessageBinding messageBinding)
            {
                WsdlNS.SoapBodyBinding bodyBinding = SoapHelper.GetOrCreateSoapBodyBinding(endpointContext, messageBinding, exporter);

                if (bodyBinding == null)
                    return;

                bodyBinding.Use = isEncoded ? WsdlNS.SoapBindingUse.Encoded : WsdlNS.SoapBindingUse.Literal;
                if (isRpc)
                {
                    string ns;
                    if (!ExportedMessages.WrapperNamespaces.TryGetValue(new MessageDescriptionDictionaryKey(endpointContext.ContractConversionContext.Contract, messageDescription), out ns))
                        ns = messageDescription.Body.WrapperNamespace;
                    bodyBinding.Namespace = ns;
                }
                if (isEncoded)
                    bodyBinding.Encoding = XmlSerializerOperationFormatter.GetEncoding(soapVersion);
            }
        protected void ExportMessagePart(WsdlNS.Message message, MessagePartDescription part, XmlQualifiedName typeName, XmlSchemaType xsdType, bool isOptional, bool isNillable, bool skipSchemaExport, bool generateElement, string wrapperNs, XmlSchemaSequence wrapperSequence, XmlSchemaSet schemaSet)
        {
            if (IsNullOrEmpty(typeName) && xsdType == null)
                return;
#if DEBUG
            if (xsdType == null)
                Fx.Assert(NamingHelper.IsValidNCName(typeName.Name), "Name value has to be a valid NCName.");
#endif
            string elementName = part.Name;
            string partName = string.IsNullOrEmpty(part.UniquePartName) ? elementName : part.UniquePartName;

            WsdlNS.MessagePart wsdlPart = null;
            if (generateElement)
            {
                if (wrapperSequence != null)
                {
                    if (!skipSchemaExport)
                        ExportLocalElement(wrapperNs, partName, part.Namespace, typeName, xsdType, part.Multiple, isOptional, isNillable, wrapperSequence, schemaSet);
                }
                else
                {
                    if (!skipSchemaExport)
                        ExportGlobalElement(elementName, part.Namespace, isNillable, typeName, xsdType, schemaSet);
                    wsdlPart = AddMessagePart(message, partName, new XmlQualifiedName(elementName, part.Namespace), XmlQualifiedName.Empty);
                }
            }
            else
            {
                if (String.IsNullOrEmpty(typeName.Name))
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxAnonymousTypeNotSupported, message.Name, partName)));

                wsdlPart = AddMessagePart(message, partName, XmlQualifiedName.Empty, typeName);
            }
            if (wsdlPart != null)
            {
                part.UniquePartName = wsdlPart.Name;
            }
        }
        void ExportMembersMapping(XmlMembersMapping membersMapping, WsdlNS.Message message, bool skipSchemaExport, bool isEncoded, bool isRpc, bool isDocWrapped, bool isHeader)
        {
            if (!skipSchemaExport)
            {
                if (isEncoded)
                    SoapExporter.ExportMembersMapping(membersMapping);
                else
                    XmlExporter.ExportMembersMapping(membersMapping, !isRpc);
            }


            if (isDocWrapped)
            {
                if (isHeader)
                {
                    Fx.Assert("Header cannot be Document Wrapped");
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Header cannot be Document Wrapped")));
                }
                AddMessagePart(message, "parameters", new XmlQualifiedName(membersMapping.XsdElementName, membersMapping.Namespace), XmlQualifiedName.Empty);
                return;
            }
            bool generateElement = !isRpc && !isEncoded;
            for (int i = 0; i < membersMapping.Count; i++)
            {
                XmlMemberMapping member = membersMapping[i];

                string partName = (isHeader || generateElement) ? NamingHelper.XmlName(member.MemberName) : member.XsdElementName;
                if (generateElement)
                    AddMessagePart(message, partName, new XmlQualifiedName(member.XsdElementName, member.Namespace), XmlQualifiedName.Empty);
                else
                {
                    if (string.IsNullOrEmpty(member.TypeName))
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxAnonymousTypeNotSupported, message.Name, partName)));

                    AddMessagePart(message, partName, XmlQualifiedName.Empty, new XmlQualifiedName(member.TypeName, member.TypeNamespace));
                }
            }
        }
Exemplo n.º 14
0
 static string CreateFaultBindingPolicyKey(WsdlNS.FaultBinding wsdlFaultBinding)
 {
     WsdlNS.OperationBinding wsdlOperationBinding = wsdlFaultBinding.OperationBinding;
     WsdlNS.Binding wsdlBinding = wsdlOperationBinding.Binding;
     if (string.IsNullOrEmpty(wsdlFaultBinding.Name))
     {
         return string.Format(CultureInfo.InvariantCulture, "{0}_{1}_Fault", wsdlBinding.Name, wsdlOperationBinding.Name);
     }
     else
     {
         return string.Format(CultureInfo.InvariantCulture, "{0}_{1}_{2}_Fault", wsdlBinding.Name, wsdlOperationBinding.Name, wsdlFaultBinding.Name);
     }
 }
Exemplo n.º 15
0
            static string CreateMessageBindingPolicyKey(WsdlNS.MessageBinding wsdlMessageBinding, MessageDirection direction)
            {
                WsdlNS.OperationBinding wsdlOperationBinding = wsdlMessageBinding.OperationBinding;
                WsdlNS.Binding wsdlBinding = wsdlOperationBinding.Binding;

                if (direction == MessageDirection.Input)
                    return string.Format(CultureInfo.InvariantCulture, "{0}_{1}_Input_policy", wsdlBinding.Name, wsdlOperationBinding.Name);
                else
                    return string.Format(CultureInfo.InvariantCulture, "{0}_{1}_output_policy", wsdlBinding.Name, wsdlOperationBinding.Name);
            }
        protected bool CreateHeaderMessage(MessageDescription message, out WsdlNS.Message wsdlMessage)
        {
            wsdlMessage = null;

            if (ExportedMessages.WsdlHeaderMessages.ContainsKey(new MessageDescriptionDictionaryKey(contractContext.Contract, message)))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.MultipleCallsToExportContractWithSameContract)));

            TypedMessageKey typedMessageKey = null;
            if (message.IsTypedMessage)
            {
                typedMessageKey = new TypedMessageKey(message.MessageType, operation.DeclaringContract.Namespace, GetExtensionData());
                if (ExportedMessages.TypedHeaderMessages.TryGetValue(typedMessageKey, out wsdlMessage))
                {
                    this.ExportedMessages.WsdlHeaderMessages.Add(new MessageDescriptionDictionaryKey(contractContext.Contract, message), wsdlMessage);
                    return false;
                }
            }

            string messageName = GetHeaderMessageName(message);
            wsdlMessage = new WsdlNS.Message();
            wsdlMessage.Name = messageName;
            contractContext.WsdlPortType.ServiceDescription.Messages.Add(wsdlMessage);
            if (message.IsTypedMessage)
                ExportedMessages.TypedHeaderMessages.Add(typedMessageKey, wsdlMessage);

            this.ExportedMessages.WsdlHeaderMessages.Add(new MessageDescriptionDictionaryKey(contractContext.Contract, message), wsdlMessage);

            return true;
        }
 string GetUniqueMessageName(WsdlNS.ServiceDescription wsdl, string messageNameBase)
 {
     return NamingHelper.GetUniqueName(messageNameBase, DoesMessageNameExist, wsdl);
 }
        void ExportAnyMessage(WsdlNS.Message message, MessagePartDescription part)
        {
            XmlSchemaSet schemas = this.exporter.GeneratedXmlSchemas;
            XmlSchema schema = SchemaHelper.GetSchema(DataContractSerializerMessageContractImporter.GenericMessageTypeName.Namespace, schemas);

            if (!schema.SchemaTypes.Contains(DataContractSerializerMessageContractImporter.GenericMessageTypeName))
            {
                XmlSchemaComplexType genericMessageType = new XmlSchemaComplexType();
                genericMessageType.Name = DataContractSerializerMessageContractImporter.GenericMessageTypeName.Name;
                XmlSchemaSequence bodySequence = new XmlSchemaSequence();
                genericMessageType.Particle = bodySequence;

                XmlSchemaAny anyElement = new XmlSchemaAny();
                anyElement.MinOccurs = 0;
                anyElement.MaxOccurs = decimal.MaxValue;
                anyElement.Namespace = "##any";

                bodySequence.Items.Add(anyElement);

                SchemaHelper.AddTypeToSchema(genericMessageType, schema, schemas);
            }
            string partName = string.IsNullOrEmpty(part.UniquePartName) ? part.Name : part.UniquePartName;
            WsdlNS.MessagePart wsdlPart = AddMessagePart(message, partName, XmlQualifiedName.Empty, DataContractSerializerMessageContractImporter.GenericMessageTypeName);
            part.UniquePartName = wsdlPart.Name;
        }
 void ExportFaultBinding(FaultDescription fault, bool isEncoded, WsdlNS.OperationBinding operationBinding)
 {
     SoapHelper.CreateSoapFaultBinding(fault.Name, endpointContext, endpointContext.GetFaultBinding(fault), isEncoded);
 }
 protected void ExportStreamBody(WsdlNS.Message message, string wrapperName, string wrapperNs, string partName, string partNs, bool isRpc, bool skipSchemaExport)
 {
     XmlSchemaSet schemas = this.exporter.GeneratedXmlSchemas;
     XmlSchema schema = SchemaHelper.GetSchema(DataContractSerializerMessageContractImporter.StreamBodyTypeName.Namespace, schemas);
     if (!schema.SchemaTypes.Contains(DataContractSerializerMessageContractImporter.StreamBodyTypeName))
     {
         XmlSchemaSimpleType streamBodyType = new XmlSchemaSimpleType();
         streamBodyType.Name = DataContractSerializerMessageContractImporter.StreamBodyTypeName.Name;
         XmlSchemaSimpleTypeRestriction contentRestriction = new XmlSchemaSimpleTypeRestriction();
         contentRestriction.BaseTypeName = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Base64Binary).QualifiedName;
         streamBodyType.Content = contentRestriction;
         SchemaHelper.AddTypeToSchema(streamBodyType, schema, schemas);
     }
     XmlSchemaSequence wrapperSequence = null;
     if (!isRpc && wrapperName != null)
         wrapperSequence = ExportWrappedPart(message, wrapperName, wrapperNs, schemas, skipSchemaExport);
     MessagePartDescription streamPart = new MessagePartDescription(partName, partNs);
     ExportMessagePart(message, streamPart, DataContractSerializerMessageContractImporter.StreamBodyTypeName, null/*xsdType*/, false/*isOptional*/, false/*isNillable*/, skipSchemaExport, !isRpc, wrapperNs, wrapperSequence, schemas);
 }
            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);
            }
 static protected WsdlNS.MessagePart AddMessagePart(WsdlNS.Message message, string partName, XmlQualifiedName elementName, XmlQualifiedName typeName)
 {
     if (message.Parts[partName] != null)
     {
         if (IsNullOrEmpty(elementName))
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SFxPartNameMustBeUniqueInRpc, partName)));
         int i = 1;
         while (message.Parts[partName + i] != null)
         {
             if (i == Int32.MaxValue)
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.SFxTooManyPartsWithSameName, partName)));
             i++;
         }
         partName = partName + i.ToString(CultureInfo.InvariantCulture);
     }
     WsdlNS.MessagePart part = new WsdlNS.MessagePart();
     part.Name = partName;
     part.Element = elementName;
     part.Type = typeName;
     message.Parts.Add(part);
     EnsureXsdImport(IsNullOrEmpty(elementName) ? typeName.Namespace : elementName.Namespace, message.ServiceDescription);
     return part;
 }
Exemplo n.º 23
0
		static XmlElement ResolvePolicy (WS.ServiceDescription sd, XmlElement policy)
		{
			if (policy.LocalName.Equals ("Policy"))
				return policy;

			var uri = policy.GetAttribute ("URI");
			if (!uri.StartsWith ("#"))
				return null;
			
			foreach (var sext in sd.Extensions) {
				var sxml = sext as XmlElement;
				if (sxml == null)
					continue;
				if (!sxml.NamespaceURI.Equals (WspNamespace))
					continue;
				if (!sxml.LocalName.Equals ("Policy"))
					continue;
				var id = sxml.GetAttribute ("Id", WsuNamespace);
				if (uri.Substring (1).Equals (id))
					return sxml;
			}

			return null;
		}
        static void EnsureXsdImport(string ns, WsdlNS.ServiceDescription wsdl)
        {
            string refNs = wsdl.TargetNamespace;
            if (!refNs.EndsWith("/", StringComparison.Ordinal))
                refNs = refNs + "/Imports";
            else
                refNs += "Imports";
            if (refNs == ns)
                refNs = wsdl.TargetNamespace;

            XmlSchema xsd = GetContainedSchema(wsdl, refNs);
            if (xsd != null)
            {
                foreach (object include in xsd.Includes)
                {
                    XmlSchemaImport import = include as XmlSchemaImport;
                    if (import != null && SchemaHelper.NamespacesEqual(import.Namespace, ns))
                        return;
                }
            }
            else
            {
                xsd = new XmlSchema();
                xsd.TargetNamespace = refNs;
                wsdl.Types.Schemas.Add(xsd);
            }

            XmlSchemaImport imp = new XmlSchemaImport();
            if (ns != null && ns.Length > 0)
                imp.Namespace = ns;
            xsd.Includes.Add(imp);
        }
Exemplo n.º 25
0
		public static PolicyAssertionCollection AssertPolicy (
			WS.ServiceDescription sd, XmlElement element, TestLabel label)
		{
			label.EnterScope ("wsp:Policy");
			Assert.That (element.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
			Assert.That (element.LocalName, Is.EqualTo ("Policy") | Is.EqualTo ("PolicyReference"), label.Get ());

			var policy = ResolvePolicy (sd, element);
			Assert.That (policy, Is.Not.Null, label.Get ());

			label.EnterScope ("wsp:ExactlyOne");
			var exactlyOne = AssertExactlyOneChildElement (policy);
			Assert.That (exactlyOne, Is.Not.Null, label.Get ());
			Assert.That (exactlyOne.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
			Assert.That (exactlyOne.LocalName, Is.EqualTo ("ExactlyOne"), label.Get ());
			label.LeaveScope ();

			label.EnterScope ("wsp:Any");
			var all = AssertExactlyOneChildElement (exactlyOne);
			Assert.That (all, Is.Not.Null, label.Get ());
			Assert.That (all.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
			Assert.That (all.LocalName, Is.EqualTo ("All"), label.Get ());
			label.LeaveScope ();

			var collection = new PolicyAssertionCollection ();

			label.EnterScope ("assertions");
			foreach (var node in all.ChildNodes) {
				if (node is XmlWhitespace)
					continue;
				Assert.That (node, Is.InstanceOfType (typeof (XmlElement)), label.ToString ());
				collection.Add ((XmlElement)node);
			}
			label.LeaveScope ();

			label.LeaveScope ();

			return collection;
		}
        static XmlSchema GetContainedSchema(WsdlNS.ServiceDescription wsdl, string ns)
        {
            foreach (XmlSchema xsd in wsdl.Types.Schemas)
                if (SchemaHelper.NamespacesEqual(xsd.TargetNamespace, ns))
                    return xsd;

            return null;
        }
Exemplo n.º 27
0
		static void TestSoapMessage (WS.MessageBinding binding, bool soap12, TestLabel label)
		{
			label.EnterScope (binding is WS.InputBinding ? "input" : "output");

			Assert.That (binding, Is.Not.Null, label.Get ());
			Assert.That (binding.Name, Is.Null, label.Get ());
			Assert.That (binding.ExtensibleAttributes, Is.Null, label.Get ());
			Assert.That (binding.Extensions, Is.Not.Null, label.Get ());
			Assert.That (binding.Extensions.Count, Is.EqualTo (1), label.Get ());
			Assert.That (binding.Extensions [0], Is.InstanceOfType (typeof (WS.SoapBodyBinding)), label.Get ());
			var body = (WS.SoapBodyBinding)binding.Extensions [0];
			TestSoapBody (body, soap12, label);
			label.LeaveScope ();
		}
        protected XmlSchemaSequence ExportWrappedPart(WsdlNS.Message message, string elementName, string elementNs, XmlSchemaSet schemaSet, bool skipSchemaExport)
        {
#if DEBUG
            Fx.Assert(NamingHelper.IsValidNCName(elementName), "Name value has to be a valid NCName.");
#endif
            AddMessagePart(message, "parameters", new XmlQualifiedName(elementName, elementNs), XmlQualifiedName.Empty);
            if (skipSchemaExport)
                return emptySequence; //return empty to denote it is wrapped part


            XmlSchemaElement wrapperGlobalElement = new XmlSchemaElement();
            wrapperGlobalElement.Name = elementName;

            XmlSchemaComplexType wrapperType = new XmlSchemaComplexType();
            wrapperGlobalElement.SchemaType = wrapperType; // generating an anonymous type for wrapper

            XmlSchemaSequence rootSequence = new XmlSchemaSequence();
            wrapperType.Particle = rootSequence;

            AddElementToSchema(wrapperGlobalElement, elementNs, schemaSet);

            return rootSequence;
        }
 public void BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments,
                          System.Xml.Schema.XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy)
 {
 }
        protected bool CreateMessage(MessageDescription message, int messageIndex, out WsdlNS.Message wsdlMessage)
        {
            wsdlMessage = null;
            bool isNewMessage = true;

            if (ExportedMessages.WsdlMessages.ContainsKey(new MessageDescriptionDictionaryKey(contractContext.Contract, message)))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.MultipleCallsToExportContractWithSameContract)));

            TypedMessageKey typedMessageKey = null;
            OperationMessageKey messageKey = null;
            if (message.IsTypedMessage)
            {
                typedMessageKey = new TypedMessageKey(message.MessageType, operation.DeclaringContract.Namespace, this.GetExtensionData());
                if (ExportedMessages.TypedMessages.TryGetValue(typedMessageKey, out wsdlMessage))
                    isNewMessage = false;
            }
            else if (operation.OperationMethod != null)
            {
                messageKey = new OperationMessageKey(operation, messageIndex);
                if (ExportedMessages.ParameterMessages.TryGetValue(messageKey, out wsdlMessage))
                    isNewMessage = false;
            }

            WsdlNS.ServiceDescription wsdl = contractContext.WsdlPortType.ServiceDescription;
            if (isNewMessage)
            {
                wsdlMessage = new WsdlNS.Message();
                wsdlMessage.Name = GetMessageName(message);
                wsdl.Messages.Add(wsdlMessage);
                if (message.IsTypedMessage)
                    ExportedMessages.TypedMessages.Add(typedMessageKey, wsdlMessage);
                else if (messageKey != null)
                    ExportedMessages.ParameterMessages.Add(messageKey, wsdlMessage);
            }

            //Add Name to OperationMessage
            WsdlNS.OperationMessage wsdlOperationMessage = contractContext.GetOperationMessage(message);
            wsdlOperationMessage.Message = new XmlQualifiedName(wsdlMessage.Name, wsdlMessage.ServiceDescription.TargetNamespace);
            this.ExportedMessages.WsdlMessages.Add(new MessageDescriptionDictionaryKey(contractContext.Contract, message), wsdlMessage);

            return isNewMessage;
        }