Esempio n. 1
0
 private static SoapOperationBinding GetSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation)
 {
     foreach (object obj2 in endpointContext.GetOperationBinding(operation).Extensions)
     {
         if (obj2 is SoapOperationBinding)
         {
             return((SoapOperationBinding)obj2);
         }
     }
     return(null);
 }
        static WsdlNS.SoapOperationBinding GetSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation)
        {
            WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);

            foreach (object o in wsdlOperationBinding.Extensions)
            {
                if (o is WsdlNS.SoapOperationBinding)
                {
                    return((WsdlNS.SoapOperationBinding)o);
                }
            }
            return(null);
        }
Esempio n. 3
0
        internal static SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter)
        {
            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
            {
                return(null);
            }
            SoapOperationBinding soapOperationBinding = GetSoapOperationBinding(endpointContext, operation);
            OperationBinding     operationBinding     = endpointContext.GetOperationBinding(operation);
            EnvelopeVersion      soapVersion          = GetSoapVersion(endpointContext.WsdlBinding);

            if (soapOperationBinding != null)
            {
                return(soapOperationBinding);
            }
            return(CreateSoapOperationBinding(soapVersion, operationBinding));
        }
        internal static WsdlNS.SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter)
        {
            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
            {
                return(null);
            }

            WsdlNS.SoapOperationBinding existingSoapOperationBinding = GetSoapOperationBinding(endpointContext, operation);
            WsdlNS.OperationBinding     wsdlOperationBinding         = endpointContext.GetOperationBinding(operation);
            EnvelopeVersion             version = GetSoapVersion(endpointContext.WsdlBinding);

            if (existingSoapOperationBinding != null)
            {
                return(existingSoapOperationBinding);
            }

            WsdlNS.SoapOperationBinding soapOperationBinding = CreateSoapOperationBinding(version, wsdlOperationBinding);
            return(soapOperationBinding);
        }
            internal void AttachPolicy(ServiceEndpoint endpoint, WsdlEndpointConversionContext endpointContext, PolicyConversionContext policyContext)
            {
                SortedList<string, string> policyKeys = new SortedList<string, string>();
                NamingHelper.DoesNameExist policyKeyIsUnique
                    = delegate(string name, object nameCollection)
                    {
                        return policyKeys.ContainsKey(name);
                    };

                string key, keyBase;
                ICollection<XmlElement> assertions;

                WsdlNS.ServiceDescription policyWsdl = endpointContext.WsdlBinding.ServiceDescription;

                assertions = policyContext.GetBindingAssertions();

                // Add [wsdl:Binding] level Policy
                WsdlNS.Binding wsdlBinding = endpointContext.WsdlBinding;
                if (assertions.Count > 0)
                {
                    keyBase = CreateBindingPolicyKey(wsdlBinding);
                    key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
                    policyKeys.Add(key, key);
                    AttachItemPolicy(assertions, key, policyWsdl, wsdlBinding);
                }

                foreach (OperationDescription operation in endpoint.Contract.Operations)
                {
                    if (!WsdlExporter.OperationIsExportable(operation))
                    {
                        continue;
                    }

                    assertions = policyContext.GetOperationBindingAssertions(operation);

                    // Add [wsdl:Binding/wsdl:operation] policy
                    if (assertions.Count > 0)
                    {
                        WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);
                        keyBase = CreateOperationBindingPolicyKey(wsdlOperationBinding);
                        key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
                        policyKeys.Add(key, key);
                        AttachItemPolicy(assertions, key, policyWsdl, wsdlOperationBinding);
                    }

                    //
                    // Add [wsdl:Binding/wsdl:operation] child policy
                    //

                    foreach (MessageDescription message in operation.Messages)
                    {
                        assertions = policyContext.GetMessageBindingAssertions(message);

                        // Add [wsdl:Binding/wsdl:operation/wsdl:(input, output, message)] policy
                        if (assertions.Count > 0)
                        {
                            WsdlNS.MessageBinding wsdlMessageBinding = endpointContext.GetMessageBinding(message);
                            keyBase = CreateMessageBindingPolicyKey(wsdlMessageBinding, message.Direction);
                            key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
                            policyKeys.Add(key, key);
                            AttachItemPolicy(assertions, key, policyWsdl, wsdlMessageBinding);
                        }
                    }

                    foreach (FaultDescription fault in operation.Faults)
                    {
                        assertions = policyContext.GetFaultBindingAssertions(fault);

                        // Add [wsdl:Binding/wsdl:operation/wsdl:fault] policy
                        if (assertions.Count > 0)
                        {
                            WsdlNS.FaultBinding wsdlFaultBinding = endpointContext.GetFaultBinding(fault);
                            keyBase = CreateFaultBindingPolicyKey(wsdlFaultBinding);
                            key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
                            policyKeys.Add(key, key);
                            AttachItemPolicy(assertions, key, policyWsdl, wsdlFaultBinding);
                        }
                    }
                }
            }
 internal void AttachPolicy(ServiceEndpoint endpoint, WsdlEndpointConversionContext endpointContext, PolicyConversionContext policyContext)
 {
     string str;
     SortedList<string, string> policyKeys = new SortedList<string, string>();
     NamingHelper.DoesNameExist doesNameExist = (name, nameCollection) => policyKeys.ContainsKey(name);
     System.Web.Services.Description.ServiceDescription serviceDescription = endpointContext.WsdlBinding.ServiceDescription;
     ICollection<XmlElement> bindingAssertions = policyContext.GetBindingAssertions();
     System.Web.Services.Description.Binding wsdlBinding = endpointContext.WsdlBinding;
     if (bindingAssertions.Count > 0)
     {
         str = NamingHelper.GetUniqueName(CreateBindingPolicyKey(wsdlBinding), doesNameExist, null);
         policyKeys.Add(str, str);
         this.AttachItemPolicy(bindingAssertions, str, serviceDescription, wsdlBinding);
     }
     foreach (OperationDescription description2 in endpoint.Contract.Operations)
     {
         if (WsdlExporter.OperationIsExportable(description2))
         {
             bindingAssertions = policyContext.GetOperationBindingAssertions(description2);
             if (bindingAssertions.Count > 0)
             {
                 OperationBinding operationBinding = endpointContext.GetOperationBinding(description2);
                 str = NamingHelper.GetUniqueName(CreateOperationBindingPolicyKey(operationBinding), doesNameExist, null);
                 policyKeys.Add(str, str);
                 this.AttachItemPolicy(bindingAssertions, str, serviceDescription, operationBinding);
             }
             foreach (MessageDescription description3 in description2.Messages)
             {
                 bindingAssertions = policyContext.GetMessageBindingAssertions(description3);
                 if (bindingAssertions.Count > 0)
                 {
                     MessageBinding messageBinding = endpointContext.GetMessageBinding(description3);
                     str = NamingHelper.GetUniqueName(CreateMessageBindingPolicyKey(messageBinding, description3.Direction), doesNameExist, null);
                     policyKeys.Add(str, str);
                     this.AttachItemPolicy(bindingAssertions, str, serviceDescription, messageBinding);
                 }
             }
             foreach (FaultDescription description4 in description2.Faults)
             {
                 bindingAssertions = policyContext.GetFaultBindingAssertions(description4);
                 if (bindingAssertions.Count > 0)
                 {
                     FaultBinding faultBinding = endpointContext.GetFaultBinding(description4);
                     str = NamingHelper.GetUniqueName(CreateFaultBindingPolicyKey(faultBinding), doesNameExist, null);
                     policyKeys.Add(str, str);
                     this.AttachItemPolicy(bindingAssertions, str, serviceDescription, faultBinding);
                 }
             }
         }
     }
 }