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


C# ServiceDescriptionCollection.GetPortType方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GetOperation

 /// <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));
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:15,代码来源:WebServiceProxyFactory.cs

示例4: AnalyzeBinding

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


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