private void ProcessWsdl()
        {
            string wsdlText;
            string portType;
            string bindingName;
            string address;
            string spnIdentity = null;
            string upnIdentity = null;
            string dnsIdentity = null;
            EndpointIdentity identity = null;
            string serializer = null;
            string contractNamespace = null;
            string bindingNamespace = null;

            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out wsdlText);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Contract, out portType);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Binding, out bindingName);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Address, out address);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.SpnIdentity, out spnIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.UpnIdentity, out upnIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.DnsIdentity, out dnsIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Serializer, out serializer);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingNamespace, out bindingNamespace);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.ContractNamespace, out contractNamespace);

            if (string.IsNullOrEmpty(wsdlText))
            {
                throw Fx.AssertAndThrow("Wsdl should not be null at this point");
            }
            if (string.IsNullOrEmpty(portType) || string.IsNullOrEmpty(bindingName) || string.IsNullOrEmpty(address))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.ContractBindingAddressCannotBeNull)));

            if (!string.IsNullOrEmpty(spnIdentity))
            {
                if ((!string.IsNullOrEmpty(upnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity)))
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                identity = EndpointIdentity.CreateSpnIdentity(spnIdentity);
            }
            else if (!string.IsNullOrEmpty(upnIdentity))
            {
                if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity)))
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                identity = EndpointIdentity.CreateUpnIdentity(upnIdentity);
            }
            else if (!string.IsNullOrEmpty(dnsIdentity))
            {
                if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(upnIdentity)))
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                identity = EndpointIdentity.CreateDnsIdentity(dnsIdentity);
            }
            else
                identity = null;

            bool removeXmlSerializerImporter = false;

            if (!String.IsNullOrEmpty(serializer))
            {
                if ("xml" != serializer && "datacontract" != serializer)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorectSerializer)));

                if ("xml" == serializer)
                    useXmlSerializer = true;
                else
                    removeXmlSerializerImporter = true; // specifying datacontract will explicitly remove the Xml importer
                // if this parameter is not set we will simply use indigo defaults
            }

            TextReader reader = new StringReader(wsdlText);
            try
            {
                try
                {
                    WsdlNS.ServiceDescription wsdl = WsdlNS.ServiceDescription.Read(reader);

                    if (String.IsNullOrEmpty(contractNamespace))
                        contractNamespace = wsdl.TargetNamespace;

                    if (String.IsNullOrEmpty(bindingNamespace))
                        bindingNamespace = wsdl.TargetNamespace;

                    WsdlNS.ServiceDescriptionCollection wsdlDocs = new WsdlNS.ServiceDescriptionCollection();
                    wsdlDocs.Add(wsdl);
                    XmlSchemaSet schemas = new XmlSchemaSet();
                    foreach (XmlSchema schema in wsdl.Types.Schemas)
                        schemas.Add(schema);

                    MetadataSet mds = new MetadataSet(WsdlImporter.CreateMetadataDocuments(wsdlDocs, schemas, null));
                    WsdlImporter importer;

                    if (useXmlSerializer)
                        importer = CreateXmlSerializerImporter(mds);
                    else
                    {
                        if (removeXmlSerializerImporter)
                            importer = CreateDataContractSerializerImporter(mds);
                        else
                            importer = new WsdlImporter(mds);
                    }

                    XmlQualifiedName contractQname = new XmlQualifiedName(portType, contractNamespace);
                    XmlQualifiedName bindingQname = new XmlQualifiedName(bindingName, bindingNamespace);

                    WsdlNS.PortType wsdlPortType = wsdlDocs.GetPortType(contractQname);
                    contractDescription = importer.ImportContract(wsdlPortType);

                    WsdlNS.Binding wsdlBinding = wsdlDocs.GetBinding(bindingQname);
                    Binding binding = importer.ImportBinding(wsdlBinding);

                    EndpointAddress endpointAddress = new EndpointAddress(new Uri(address), identity, (AddressHeaderCollection)null);

                    serviceEndpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress);

                    ComPlusWsdlChannelBuilderTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationWsdlChannelBuilderLoaded,
                        SR.TraceCodeComIntegrationWsdlChannelBuilderLoaded, bindingQname, contractQname, wsdl, contractDescription, binding, wsdl.Types.Schemas);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                        throw;

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.FailedImportOfWsdl, e.Message)));
                }
            }
            finally
            {
                IDisposable disposee = reader;
                disposee.Dispose();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Search and returns the operation that matches the specified method.
 /// </summary>
 private Operation GetOperation(ServiceDescriptionCollection descriptions, Binding binding, MethodInfo method)
 {
     PortType portType = descriptions.GetPortType(binding.Type);
     foreach (Operation operation in portType.Operations)
     {
         if (operation.Name == method.Name)
         {
             return operation;
         }
     }
     throw new ApplicationException(String.Format("No Operation has been found for the method '{0}' in the WSDL document located at '{1}'.", method.Name, serviceUri.Description));
 }
 private void ProcessWsdl()
 {
     string str;
     string str2;
     string str3;
     string str4;
     string str5 = null;
     string str6 = null;
     string str7 = null;
     EndpointIdentity identity = null;
     string str8 = null;
     string targetNamespace = null;
     string str10 = null;
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out str);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Contract, out str2);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Binding, out str3);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Address, out str4);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.SpnIdentity, out str5);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.UpnIdentity, out str6);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.DnsIdentity, out str7);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Serializer, out str8);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingNamespace, out str10);
     this.propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.ContractNamespace, out targetNamespace);
     if (string.IsNullOrEmpty(str))
     {
         throw Fx.AssertAndThrow("Wsdl should not be null at this point");
     }
     if ((string.IsNullOrEmpty(str2) || string.IsNullOrEmpty(str3)) || string.IsNullOrEmpty(str4))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(System.ServiceModel.SR.GetString("ContractBindingAddressCannotBeNull")));
     }
     if (!string.IsNullOrEmpty(str5))
     {
         if (!string.IsNullOrEmpty(str6) || !string.IsNullOrEmpty(str7))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(System.ServiceModel.SR.GetString("MonikerIncorrectServerIdentity")));
         }
         identity = EndpointIdentity.CreateSpnIdentity(str5);
     }
     else if (!string.IsNullOrEmpty(str6))
     {
         if (!string.IsNullOrEmpty(str5) || !string.IsNullOrEmpty(str7))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(System.ServiceModel.SR.GetString("MonikerIncorrectServerIdentity")));
         }
         identity = EndpointIdentity.CreateUpnIdentity(str6);
     }
     else if (!string.IsNullOrEmpty(str7))
     {
         if (!string.IsNullOrEmpty(str5) || !string.IsNullOrEmpty(str6))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(System.ServiceModel.SR.GetString("MonikerIncorrectServerIdentity")));
         }
         identity = EndpointIdentity.CreateDnsIdentity(str7);
     }
     else
     {
         identity = null;
     }
     bool flag = false;
     if (!string.IsNullOrEmpty(str8))
     {
         if (("xml" != str8) && ("datacontract" != str8))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(System.ServiceModel.SR.GetString("MonikerIncorectSerializer")));
         }
         if ("xml" == str8)
         {
             this.useXmlSerializer = true;
         }
         else
         {
             flag = true;
         }
     }
     TextReader textReader = new StringReader(str);
     try
     {
         WsdlImporter importer;
         System.Web.Services.Description.ServiceDescription serviceDescription = System.Web.Services.Description.ServiceDescription.Read(textReader);
         if (string.IsNullOrEmpty(targetNamespace))
         {
             targetNamespace = serviceDescription.TargetNamespace;
         }
         if (string.IsNullOrEmpty(str10))
         {
             str10 = serviceDescription.TargetNamespace;
         }
         ServiceDescriptionCollection wsdlDocuments = new ServiceDescriptionCollection();
         wsdlDocuments.Add(serviceDescription);
         XmlSchemaSet xmlSchemas = new XmlSchemaSet();
         foreach (System.Xml.Schema.XmlSchema schema in serviceDescription.Types.Schemas)
         {
             xmlSchemas.Add(schema);
         }
         MetadataSet metaData = new MetadataSet(WsdlImporter.CreateMetadataDocuments(wsdlDocuments, xmlSchemas, null));
         if (this.useXmlSerializer)
         {
             importer = this.CreateXmlSerializerImporter(metaData);
         }
         else if (flag)
         {
             importer = this.CreateDataContractSerializerImporter(metaData);
         }
         else
         {
             importer = new WsdlImporter(metaData);
         }
         XmlQualifiedName name = new XmlQualifiedName(str2, targetNamespace);
         XmlQualifiedName name2 = new XmlQualifiedName(str3, str10);
         PortType portType = wsdlDocuments.GetPortType(name);
         this.contractDescription = importer.ImportContract(portType);
         System.Web.Services.Description.Binding wsdlBinding = wsdlDocuments.GetBinding(name2);
         System.ServiceModel.Channels.Binding binding = importer.ImportBinding(wsdlBinding);
         EndpointAddress address = new EndpointAddress(new Uri(str4), identity, null);
         this.serviceEndpoint = new ServiceEndpoint(this.contractDescription, binding, address);
         ComPlusWsdlChannelBuilderTrace.Trace(TraceEventType.Verbose, 0x5001d, "TraceCodeComIntegrationWsdlChannelBuilderLoaded", name2, name, serviceDescription, this.contractDescription, binding, serviceDescription.Types.Schemas);
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(System.ServiceModel.SR.GetString("FailedImportOfWsdl", new object[] { exception.Message })));
     }
     finally
     {
         IDisposable disposable = textReader;
         disposable.Dispose();
     }
 }
Ejemplo n.º 4
0
        internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            bool        flag     = false;
            bool        flag2    = false;
            SoapBinding binding2 = (SoapBinding)binding.Extensions.Find(typeof(SoapBinding));

            if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding)))
            {
                return(false);
            }
            SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style;

            if (binding2.Transport.Length == 0)
            {
                violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" }));
            }
            else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http")
            {
                violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport }));
            }
            PortType  portType  = descriptions.GetPortType(binding.Type);
            Hashtable hashtable = new Hashtable();

            if (portType != null)
            {
                foreach (Operation operation in portType.Operations)
                {
                    if (operation.Messages.Flow == OperationFlow.Notification)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (operation.Messages.Flow == OperationFlow.SolicitResponse)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (hashtable[operation.Name] != null)
                    {
                        violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                    }
                    else
                    {
                        OperationBinding binding3 = null;
                        foreach (OperationBinding binding4 in binding.Operations)
                        {
                            if (operation.IsBoundBy(binding4))
                            {
                                if (binding3 != null)
                                {
                                    violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace }));
                                }
                                binding3 = binding4;
                            }
                        }
                        if (binding3 == null)
                        {
                            violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                        }
                        else
                        {
                            hashtable.Add(operation.Name, operation);
                        }
                    }
                }
            }
            Hashtable        wireSignatures = new Hashtable();
            SoapBindingStyle style2         = SoapBindingStyle.Default;

            foreach (OperationBinding binding5 in binding.Operations)
            {
                SoapBindingStyle style3 = style;
                string           name   = binding5.Name;
                if (name != null)
                {
                    if (hashtable[name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                    Operation            operation2 = FindOperation(portType.Operations, binding5);
                    SoapOperationBinding binding6   = (SoapOperationBinding)binding5.Extensions.Find(typeof(SoapOperationBinding));
                    if (binding6 != null)
                    {
                        if (style2 == SoapBindingStyle.Default)
                        {
                            style2 = binding6.Style;
                        }
                        flag  |= style2 != binding6.Style;
                        style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style;
                    }
                    if (binding5.Input != null)
                    {
                        SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded))
                        {
                            Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1));
                                int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length;
                                CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                                if (((num == 0) && (message != null)) && (message.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    if (binding5.Output != null)
                    {
                        SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded))
                        {
                            Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1));
                                int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length;
                                CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                                if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    foreach (FaultBinding binding9 in binding5.Faults)
                    {
                        foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions)
                        {
                            if (extension is SoapFaultBinding)
                            {
                                SoapFaultBinding item = (SoapFaultBinding)extension;
                                if (item.Use == SoapBindingUse.Encoded)
                                {
                                    violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                }
                                else
                                {
                                    if ((item.Name == null) || (item.Name.Length == 0))
                                    {
                                        violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    else if (item.Name != binding9.Name)
                                    {
                                        violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    if ((item.Namespace != null) && (item.Namespace.Length > 0))
                                    {
                                        violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                    }
                                }
                            }
                        }
                    }
                    if (hashtable[binding5.Name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                }
            }
            if (flag2)
            {
                violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" }));
            }
            if (flag)
            {
                violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace }));
            }
            return(true);
        }
        private void ProcessWsdl()
        {
            string           wsdlText;
            string           portType;
            string           bindingName;
            string           address;
            string           spnIdentity       = null;
            string           upnIdentity       = null;
            string           dnsIdentity       = null;
            EndpointIdentity identity          = null;
            string           serializer        = null;
            string           contractNamespace = null;
            string           bindingNamespace  = null;

            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out wsdlText);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Contract, out portType);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Binding, out bindingName);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Address, out address);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.SpnIdentity, out spnIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.UpnIdentity, out upnIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.DnsIdentity, out dnsIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Serializer, out serializer);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingNamespace, out bindingNamespace);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.ContractNamespace, out contractNamespace);

            if (string.IsNullOrEmpty(wsdlText))
            {
                throw Fx.AssertAndThrow("Wsdl should not be null at this point");
            }
            if (string.IsNullOrEmpty(portType) || string.IsNullOrEmpty(bindingName) || string.IsNullOrEmpty(address))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.ContractBindingAddressCannotBeNull)));
            }

            if (!string.IsNullOrEmpty(spnIdentity))
            {
                if ((!string.IsNullOrEmpty(upnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                }
                identity = EndpointIdentity.CreateSpnIdentity(spnIdentity);
            }
            else if (!string.IsNullOrEmpty(upnIdentity))
            {
                if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                }
                identity = EndpointIdentity.CreateUpnIdentity(upnIdentity);
            }
            else if (!string.IsNullOrEmpty(dnsIdentity))
            {
                if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(upnIdentity)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                }
                identity = EndpointIdentity.CreateDnsIdentity(dnsIdentity);
            }
            else
            {
                identity = null;
            }

            bool removeXmlSerializerImporter = false;

            if (!String.IsNullOrEmpty(serializer))
            {
                if ("xml" != serializer && "datacontract" != serializer)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorectSerializer)));
                }

                if ("xml" == serializer)
                {
                    useXmlSerializer = true;
                }
                else
                {
                    removeXmlSerializerImporter = true; // specifying datacontract will explicitly remove the Xml importer
                }
                // if this parameter is not set we will simply use indigo defaults
            }

            TextReader reader = new StringReader(wsdlText);

            try
            {
                try
                {
                    WsdlNS.ServiceDescription wsdl = WsdlNS.ServiceDescription.Read(reader);

                    if (String.IsNullOrEmpty(contractNamespace))
                    {
                        contractNamespace = wsdl.TargetNamespace;
                    }

                    if (String.IsNullOrEmpty(bindingNamespace))
                    {
                        bindingNamespace = wsdl.TargetNamespace;
                    }

                    WsdlNS.ServiceDescriptionCollection wsdlDocs = new WsdlNS.ServiceDescriptionCollection();
                    wsdlDocs.Add(wsdl);
                    XmlSchemaSet schemas = new XmlSchemaSet();
                    foreach (XmlSchema schema in wsdl.Types.Schemas)
                    {
                        schemas.Add(schema);
                    }

                    MetadataSet  mds = new MetadataSet(WsdlImporter.CreateMetadataDocuments(wsdlDocs, schemas, null));
                    WsdlImporter importer;

                    if (useXmlSerializer)
                    {
                        importer = CreateXmlSerializerImporter(mds);
                    }
                    else
                    {
                        if (removeXmlSerializerImporter)
                        {
                            importer = CreateDataContractSerializerImporter(mds);
                        }
                        else
                        {
                            importer = new WsdlImporter(mds);
                        }
                    }

                    XmlQualifiedName contractQname = new XmlQualifiedName(portType, contractNamespace);
                    XmlQualifiedName bindingQname  = new XmlQualifiedName(bindingName, bindingNamespace);

                    WsdlNS.PortType wsdlPortType = wsdlDocs.GetPortType(contractQname);
                    contractDescription = importer.ImportContract(wsdlPortType);

                    WsdlNS.Binding wsdlBinding = wsdlDocs.GetBinding(bindingQname);
                    Binding        binding     = importer.ImportBinding(wsdlBinding);

                    EndpointAddress endpointAddress = new EndpointAddress(new Uri(address), identity, (AddressHeaderCollection)null);

                    serviceEndpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress);

                    ComPlusWsdlChannelBuilderTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationWsdlChannelBuilderLoaded,
                                                         SR.TraceCodeComIntegrationWsdlChannelBuilderLoaded, bindingQname, contractQname, wsdl, contractDescription, binding, wsdl.Types.Schemas);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.FailedImportOfWsdl, e.Message)));
                }
            }
            finally
            {
                IDisposable disposee = reader;
                disposee.Dispose();
            }
        }
 internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
     bool flag = false;
     bool flag2 = false;
     SoapBinding binding2 = (SoapBinding) binding.Extensions.Find(typeof(SoapBinding));
     if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding)))
     {
         return false;
     }
     SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style;
     if (binding2.Transport.Length == 0)
     {
         violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" }));
     }
     else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http")
     {
         violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport }));
     }
     PortType portType = descriptions.GetPortType(binding.Type);
     Hashtable hashtable = new Hashtable();
     if (portType != null)
     {
         foreach (Operation operation in portType.Operations)
         {
             if (operation.Messages.Flow == OperationFlow.Notification)
             {
                 violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
             }
             if (operation.Messages.Flow == OperationFlow.SolicitResponse)
             {
                 violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
             }
             if (hashtable[operation.Name] != null)
             {
                 violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
             }
             else
             {
                 OperationBinding binding3 = null;
                 foreach (OperationBinding binding4 in binding.Operations)
                 {
                     if (operation.IsBoundBy(binding4))
                     {
                         if (binding3 != null)
                         {
                             violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace }));
                         }
                         binding3 = binding4;
                     }
                 }
                 if (binding3 == null)
                 {
                     violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                 }
                 else
                 {
                     hashtable.Add(operation.Name, operation);
                 }
             }
         }
     }
     Hashtable wireSignatures = new Hashtable();
     SoapBindingStyle style2 = SoapBindingStyle.Default;
     foreach (OperationBinding binding5 in binding.Operations)
     {
         SoapBindingStyle style3 = style;
         string name = binding5.Name;
         if (name != null)
         {
             if (hashtable[name] == null)
             {
                 violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
             }
             Operation operation2 = FindOperation(portType.Operations, binding5);
             SoapOperationBinding binding6 = (SoapOperationBinding) binding5.Extensions.Find(typeof(SoapOperationBinding));
             if (binding6 != null)
             {
                 if (style2 == SoapBindingStyle.Default)
                 {
                     style2 = binding6.Style;
                 }
                 flag |= style2 != binding6.Style;
                 style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style;
             }
             if (binding5.Input != null)
             {
                 SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                 if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded))
                 {
                     Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message));
                     if (style3 == SoapBindingStyle.Rpc)
                     {
                         CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                     }
                     else
                     {
                         flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1));
                         int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length;
                         CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                         if (((num == 0) && (message != null)) && (message.Parts.Count > 1))
                         {
                             violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                         }
                     }
                 }
             }
             if (binding5.Output != null)
             {
                 SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                 if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded))
                 {
                     Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message));
                     if (style3 == SoapBindingStyle.Rpc)
                     {
                         CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                     }
                     else
                     {
                         flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1));
                         int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length;
                         CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                         if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1))
                         {
                             violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                         }
                     }
                 }
             }
             foreach (FaultBinding binding9 in binding5.Faults)
             {
                 foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions)
                 {
                     if (extension is SoapFaultBinding)
                     {
                         SoapFaultBinding item = (SoapFaultBinding) extension;
                         if (item.Use == SoapBindingUse.Encoded)
                         {
                             violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                         }
                         else
                         {
                             if ((item.Name == null) || (item.Name.Length == 0))
                             {
                                 violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                             }
                             else if (item.Name != binding9.Name)
                             {
                                 violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                             }
                             if ((item.Namespace != null) && (item.Namespace.Length > 0))
                             {
                                 violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                             }
                         }
                     }
                 }
             }
             if (hashtable[binding5.Name] == null)
             {
                 violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
             }
         }
     }
     if (flag2)
     {
         violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" }));
     }
     if (flag)
     {
         violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace }));
     }
     return true;
 }