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


C# WsdlImporter.AddWarning方法代码示例

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


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

示例1: ImportNetTcpBinding

		bool ImportNetTcpBinding (
			WsdlImporter importer, WsdlEndpointConversionContext context,
			CustomBinding custom, WS.Soap12Binding soap)
		{
			TcpTransportBindingElement transportElement = null;
			BinaryMessageEncodingBindingElement binaryElement = null;
			TransactionFlowBindingElement transactionFlowElement = null;
			WindowsStreamSecurityBindingElement windowsStreamElement = null;
			SslStreamSecurityBindingElement sslStreamElement = null;
			bool foundUnknownElement = false;
			
			foreach (var element in custom.Elements) {
				if (element is TcpTransportBindingElement)
					transportElement = (TcpTransportBindingElement)element;
				else if (element is BinaryMessageEncodingBindingElement)
					binaryElement = (BinaryMessageEncodingBindingElement)element;
				else if (element is TransactionFlowBindingElement)
					transactionFlowElement = (TransactionFlowBindingElement)element;
				else if (element is WindowsStreamSecurityBindingElement)
					windowsStreamElement = (WindowsStreamSecurityBindingElement)element;
				else if (element is SslStreamSecurityBindingElement)
					sslStreamElement = (SslStreamSecurityBindingElement)element;
				else {
					importer.AddWarning (
						"Found unknown binding element `{0}' while importing " +
						"binding `{1}'.", element.GetType (), custom.Name);
					foundUnknownElement = true;
				}
			}

			if (foundUnknownElement)
				return false;

			if (transportElement == null) {
				importer.AddWarning (
					"Missing TcpTransportBindingElement while importing " +
					"binding `{0}'.", custom.Name);
				return false;
			}
			if (binaryElement == null) {
				importer.AddWarning (
					"Missing BinaryMessageEncodingBindingElement while importing " +
					"binding `{0}'.", custom.Name);
				return false;
			}

			if ((windowsStreamElement != null) && (sslStreamElement != null)) {
				importer.AddWarning (
					"Found both WindowsStreamSecurityBindingElement and " +
					"SslStreamSecurityBindingElement while importing binding `{0}.",
					custom.Name);
				return false;
			}

			NetTcpSecurity security;
			if (windowsStreamElement != null) {
				security = new NetTcpSecurity (SecurityMode.Transport);
				security.Transport.ProtectionLevel = windowsStreamElement.ProtectionLevel;
			} else if (sslStreamElement != null) {
				security = new NetTcpSecurity (SecurityMode.TransportWithMessageCredential);
			} else {
				security = new NetTcpSecurity (SecurityMode.None);
			}

			var netTcp = new NetTcpBinding (transportElement, security, false);

			netTcp.Name = context.Endpoint.Binding.Name;
			netTcp.Namespace = context.Endpoint.Binding.Namespace;

			context.Endpoint.Binding = netTcp;
			return true;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:72,代码来源:StandardBindingImporter.cs

示例2: ImportBasicHttpBinding

		bool ImportBasicHttpBinding (
			WsdlImporter importer, WsdlEndpointConversionContext context,
			CustomBinding custom, WS.SoapBinding soap)
		{
			TransportBindingElement transportElement = null;
			MtomMessageEncodingBindingElement mtomElement = null;
			TextMessageEncodingBindingElement textElement = null;
			bool foundUnknownElement = false;

			foreach (var element in custom.Elements) {
				if (element is TransportBindingElement)
					transportElement = (TransportBindingElement)element;
				else if (element is MtomMessageEncodingBindingElement)
					mtomElement = (MtomMessageEncodingBindingElement)element;
				else if (element is TextMessageEncodingBindingElement)
					textElement = (TextMessageEncodingBindingElement)element;
				else {
					importer.AddWarning (
						"Found unknown binding element `{0}' while attempting " +
						"to import binding `{0}'.", element.GetType (),
						custom.Name);
					foundUnknownElement = true;
				}
			}

			if (foundUnknownElement)
				return false;

			if ((mtomElement != null) && (textElement != null)) {
				// FIXME: Should never happen
				importer.AddWarning (
					"Found both MtomMessageEncodingBindingElement and " +
					"TextMessageEncodingBindingElement while attempting to " +
					"import binding `{0}'.", custom.Name);
				return false;
			}

			BasicHttpBinding httpBinding;
			AuthenticationSchemes authScheme;

			/*
			 * FIXME: Maybe make the BasicHttpBinding use the transport element
			 * that we created with the TransportBindingElementImporter ?
			 * 
			 * There seems to be no public API to do that, so maybe add a private .ctor ?
			 * 
			 */

			var httpsTransport = transportElement as HttpsTransportBindingElement;
			var httpTransport = transportElement as HttpTransportBindingElement;

			if (httpsTransport != null) {
				httpBinding = new BasicHttpBinding (BasicHttpSecurityMode.Transport);
				authScheme = httpsTransport.AuthenticationScheme;
			} else if (httpTransport != null) {
				authScheme = httpTransport.AuthenticationScheme;
				if ((authScheme != AuthenticationSchemes.None) &&
					(authScheme != AuthenticationSchemes.Anonymous))
					httpBinding = new BasicHttpBinding (
						BasicHttpSecurityMode.TransportCredentialOnly);
				else
					httpBinding = new BasicHttpBinding ();
			} else {
				httpBinding = new BasicHttpBinding ();
				authScheme = AuthenticationSchemes.Anonymous;
			}

			if (mtomElement != null)
				httpBinding.MessageEncoding = WSMessageEncoding.Mtom;
			else if (textElement != null)
				httpBinding.MessageEncoding = WSMessageEncoding.Text;
			else {
				importer.AddWarning (
					"Found neither MtomMessageEncodingBindingElement nor " +
					"TextMessageEncodingBindingElement while attempting to " +
					"import binding `{0}'.", custom.Name);
				return false;
			}

			httpBinding.Name = context.Endpoint.Binding.Name;
			httpBinding.Namespace = context.Endpoint.Binding.Namespace;

			switch (authScheme) {
			case AuthenticationSchemes.None:
			case AuthenticationSchemes.Anonymous:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
				break;
			case AuthenticationSchemes.Basic:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
				break;
			case AuthenticationSchemes.Digest:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest;
				break;
			case AuthenticationSchemes.Ntlm:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
				break;
			case AuthenticationSchemes.Negotiate:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
				break;
			default:
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:StandardBindingImporter.cs


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