当前位置: 首页>>代码示例>>C#>>正文


C# ServiceDescriptionCollection.GetBinding方法代码示例

本文整理汇总了C#中System.Web.Services.Description.ServiceDescriptionCollection.GetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceDescriptionCollection.GetBinding方法的具体用法?C# ServiceDescriptionCollection.GetBinding怎么用?C# ServiceDescriptionCollection.GetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Services.Description.ServiceDescriptionCollection的用法示例。


在下文中一共展示了ServiceDescriptionCollection.GetBinding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessWsdl


//.........这里部分代码省略.........
     {
         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();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:WsdlServiceChannelBuilder.cs

示例2: ProcessWsdl


//.........这里部分代码省略.........
            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();
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:WsdlServiceChannelBuilder.cs

示例3: CheckExtensions

 private static void CheckExtensions(ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
     Hashtable hashtable = new Hashtable();
     foreach (ServiceDescription description in descriptions)
     {
         if ((ServiceDescription.GetConformanceClaims(description.Types.DocumentationElement) == WsiProfiles.BasicProfile1_1) && !CheckExtensions(description.Extensions))
         {
             violations.Add("R2026", System.Web.Services.Res.GetString("Element", new object[] { "wsdl:types", description.TargetNamespace }));
         }
         foreach (Service service in description.Services)
         {
             foreach (Port port in service.Ports)
             {
                 if (ServiceDescription.GetConformanceClaims(port.DocumentationElement) == WsiProfiles.BasicProfile1_1)
                 {
                     if (!CheckExtensions(port.Extensions))
                     {
                         violations.Add("R2026", System.Web.Services.Res.GetString("Port", new object[] { port.Name, service.Name, description.TargetNamespace }));
                     }
                     Binding binding = descriptions.GetBinding(port.Binding);
                     if (hashtable[binding] != null)
                     {
                         CheckExtensions(binding, description, violations);
                         hashtable.Add(binding, binding);
                     }
                 }
             }
         }
         foreach (Binding binding2 in description.Bindings)
         {
             SoapBinding binding3 = (SoapBinding) binding2.Extensions.Find(typeof(SoapBinding));
             if (((binding3 != null) && !(binding3.GetType() != typeof(SoapBinding))) && ((hashtable[binding2] == null) && (ServiceDescription.GetConformanceClaims(binding2.DocumentationElement) == WsiProfiles.BasicProfile1_1)))
             {
                 CheckExtensions(binding2, description, violations);
                 hashtable.Add(binding2, binding2);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:WebServicesInteroperability.cs


注:本文中的System.Web.Services.Description.ServiceDescriptionCollection.GetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。