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


C# WsdlEndpointConversionContext.AddOperationBinding方法代码示例

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


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

示例1: ExportEndpoint

        void ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, BindingParameterCollection bindingParameters)
        {
            if (endpoint.Binding == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.EndpointsMustHaveAValidBinding1, endpoint.Name)));

            EndpointDictionaryKey endpointKey = new EndpointDictionaryKey(endpoint, wsdlServiceQName);

            try
            {
                if (exportedEndpoints.ContainsKey(endpointKey))
                    return;

                this.ExportContract(endpoint.Contract);

                // Retreive Conversion Context for Contract;
                // Note: Contract must have already been exported at this point.
                WsdlContractConversionContext contractContext = this.exportedContracts[endpoint.Contract];


                bool newWsdlBinding, bindingNameWasUniquified;
                WsdlNS.Port wsdlPort;
                WsdlNS.Binding wsdlBinding;
                wsdlBinding = CreateWsdlBindingAndPort(endpoint, wsdlServiceQName, out wsdlPort, out newWsdlBinding, out bindingNameWasUniquified);


                if (!newWsdlBinding && wsdlPort == null)
                    return;

                // Create an Endpoint conversion context based on 
                // the contract's conversion context (reuse contract correlation information)
                WsdlEndpointConversionContext endpointContext;
                if (newWsdlBinding)
                {
                    endpointContext = new WsdlEndpointConversionContext(contractContext, endpoint, wsdlBinding, wsdlPort);

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

                        WsdlNS.OperationBinding wsdlOperationBinding = CreateWsdlOperationBinding(endpoint.Contract, operation);
                        wsdlBinding.Operations.Add(wsdlOperationBinding);

                        endpointContext.AddOperationBinding(operation, wsdlOperationBinding);

                        foreach (MessageDescription message in operation.Messages)
                        {
                            WsdlNS.MessageBinding wsdlMessageBinding = CreateWsdlMessageBinding(message, endpoint.Binding, wsdlOperationBinding);
                            endpointContext.AddMessageBinding(message, wsdlMessageBinding);
                        }

                        foreach (FaultDescription fault in operation.Faults)
                        {
                            WsdlNS.FaultBinding wsdlFaultBinding = CreateWsdlFaultBinding(fault, endpoint.Binding, wsdlOperationBinding);
                            endpointContext.AddFaultBinding(fault, wsdlFaultBinding);
                        }
                    }

                    // CSDMain 180381:  Added internal functionality for passing BindingParameters into the ExportPolicy process via PolicyConversionContext.
                    // However, in order to not change existing behavior, we only call the internal ExportPolicy method which accepts BindingParameters if they are not null
                    // (non-null binding parameters can only be passed in via internal code paths).  Otherwise, we call the existing ExportPolicy method, just like before.
                    PolicyConversionContext policyContext;
                    if (bindingParameters == null)
                    {
                        policyContext = this.ExportPolicy(endpoint);
                    }
                    else
                    {
                        policyContext = this.ExportPolicy(endpoint, bindingParameters);
                    }
                    // consider factoring this out of wsdl exporter
                    new WSPolicyAttachmentHelper(this.PolicyVersion).AttachPolicy(endpoint, endpointContext, policyContext);
                    exportedBindings.Add(new BindingDictionaryKey(endpoint.Contract, endpoint.Binding), endpointContext);
                }
                else
                {
                    endpointContext = new WsdlEndpointConversionContext(exportedBindings[new BindingDictionaryKey(endpoint.Contract, endpoint.Binding)], endpoint, wsdlPort);
                }

                CallExportEndpoint(endpointContext);
                exportedEndpoints.Add(endpointKey, endpoint);
                if (bindingNameWasUniquified)
                    Errors.Add(new MetadataConversionError(SR.GetString(SR.WarnDuplicateBindingQNameNameOnExport, endpoint.Binding.Name, endpoint.Binding.Namespace, endpoint.Contract.Name), true /*isWarning*/));
            }
            catch
            {
                isFaulted = true;
                throw;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:92,代码来源:WsdlExporter.cs

示例2: ExportEndpoint

 private void ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName)
 {
     if (endpoint.Binding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("EndpointsMustHaveAValidBinding1", new object[] { endpoint.Name })));
     }
     EndpointDictionaryKey key = new EndpointDictionaryKey(endpoint, wsdlServiceQName);
     try
     {
         if (!this.exportedEndpoints.ContainsKey(key))
         {
             bool flag;
             bool flag2;
             Port port;
             this.ExportContract(endpoint.Contract);
             WsdlContractConversionContext contractContext = this.exportedContracts[endpoint.Contract];
             System.Web.Services.Description.Binding wsdlBinding = this.CreateWsdlBindingAndPort(endpoint, wsdlServiceQName, out port, out flag, out flag2);
             if (flag || (port != null))
             {
                 WsdlEndpointConversionContext context2;
                 if (flag)
                 {
                     context2 = new WsdlEndpointConversionContext(contractContext, endpoint, wsdlBinding, port);
                     foreach (OperationDescription description in endpoint.Contract.Operations)
                     {
                         if (OperationIsExportable(description))
                         {
                             OperationBinding bindingOperation = this.CreateWsdlOperationBinding(endpoint.Contract, description);
                             wsdlBinding.Operations.Add(bindingOperation);
                             context2.AddOperationBinding(description, bindingOperation);
                             foreach (MessageDescription description2 in description.Messages)
                             {
                                 MessageBinding wsdlMessageBinding = this.CreateWsdlMessageBinding(description2, endpoint.Binding, bindingOperation);
                                 context2.AddMessageBinding(description2, wsdlMessageBinding);
                             }
                             foreach (FaultDescription description3 in description.Faults)
                             {
                                 FaultBinding wsdlFaultBinding = this.CreateWsdlFaultBinding(description3, endpoint.Binding, bindingOperation);
                                 context2.AddFaultBinding(description3, wsdlFaultBinding);
                             }
                         }
                     }
                     PolicyConversionContext policyContext = base.ExportPolicy(endpoint);
                     new WSPolicyAttachmentHelper(base.PolicyVersion).AttachPolicy(endpoint, context2, policyContext);
                     this.exportedBindings.Add(new BindingDictionaryKey(endpoint.Contract, endpoint.Binding), context2);
                 }
                 else
                 {
                     context2 = new WsdlEndpointConversionContext(this.exportedBindings[new BindingDictionaryKey(endpoint.Contract, endpoint.Binding)], endpoint, port);
                 }
                 this.CallExportEndpoint(context2);
                 this.exportedEndpoints.Add(key, endpoint);
                 if (flag2)
                 {
                     base.Errors.Add(new MetadataConversionError(System.ServiceModel.SR.GetString("WarnDuplicateBindingQNameNameOnExport", new object[] { endpoint.Binding.Name, endpoint.Binding.Namespace, endpoint.Contract.Name }), true));
                 }
             }
         }
     }
     catch
     {
         this.isFaulted = true;
         throw;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:65,代码来源:WsdlExporter.cs


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