本文整理汇总了C#中System.ServiceModel.Description.WsdlEndpointConversionContext.GetMessageBinding方法的典型用法代码示例。如果您正苦于以下问题:C# WsdlEndpointConversionContext.GetMessageBinding方法的具体用法?C# WsdlEndpointConversionContext.GetMessageBinding怎么用?C# WsdlEndpointConversionContext.GetMessageBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Description.WsdlEndpointConversionContext
的用法示例。
在下文中一共展示了WsdlEndpointConversionContext.GetMessageBinding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBindingElements
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
#pragma warning suppress 56506 // [....], these properties cannot be null in this context
if (context.Endpoint.Binding == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding");
}
BindingElementCollection bindingElements = GetBindingElements(context);
MessageEncodingBindingElement messageEncodingBindingElement = bindingElements.Find<MessageEncodingBindingElement>();
TextMessageEncodingBindingElement textEncodingBindingElement = messageEncodingBindingElement as TextMessageEncodingBindingElement;
if (messageEncodingBindingElement != null)
{
Type elementType = messageEncodingBindingElement.GetType();
if (elementType != typeof(TextMessageEncodingBindingElement)
&& elementType != typeof(BinaryMessageEncodingBindingElement)
&& elementType != typeof(MtomMessageEncodingBindingElement))
return;
}
EnsureMessageEncoding(context, messageEncodingBindingElement);
foreach (OperationBinding wsdlOperationBinding in context.WsdlBinding.Operations)
{
OperationDescription operation = context.GetOperationDescription(wsdlOperationBinding);
for (int i = 0; i < operation.Messages.Count; i++)
{
MessageDescription message = operation.Messages[i];
MessageBinding wsdlMessageBinding = context.GetMessageBinding(message);
ImportMessageSoapAction(context.ContractConversionContext, message, wsdlMessageBinding, i != 0 /*isResponse*/);
}
foreach (FaultDescription fault in operation.Faults)
{
FaultBinding wsdlFaultBinding = context.GetFaultBinding(fault);
if (wsdlFaultBinding != null)
{
ImportFaultSoapAction(context.ContractConversionContext, fault, wsdlFaultBinding);
}
}
}
}
示例2: AttachPolicy
internal void AttachPolicy(ServiceEndpoint endpoint, WsdlEndpointConversionContext endpointContext, PolicyConversionContext policyContext)
{
SortedList<string, string> policyKeys = new SortedList<string, string>();
NamingHelper.DoesNameExist policyKeyIsUnique
= delegate(string name, object nameCollection)
{
return policyKeys.ContainsKey(name);
};
string key, keyBase;
ICollection<XmlElement> assertions;
WsdlNS.ServiceDescription policyWsdl = endpointContext.WsdlBinding.ServiceDescription;
assertions = policyContext.GetBindingAssertions();
// Add [wsdl:Binding] level Policy
WsdlNS.Binding wsdlBinding = endpointContext.WsdlBinding;
if (assertions.Count > 0)
{
keyBase = CreateBindingPolicyKey(wsdlBinding);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlBinding);
}
foreach (OperationDescription operation in endpoint.Contract.Operations)
{
if (!WsdlExporter.OperationIsExportable(operation))
{
continue;
}
assertions = policyContext.GetOperationBindingAssertions(operation);
// Add [wsdl:Binding/wsdl:operation] policy
if (assertions.Count > 0)
{
WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);
keyBase = CreateOperationBindingPolicyKey(wsdlOperationBinding);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlOperationBinding);
}
//
// Add [wsdl:Binding/wsdl:operation] child policy
//
foreach (MessageDescription message in operation.Messages)
{
assertions = policyContext.GetMessageBindingAssertions(message);
// Add [wsdl:Binding/wsdl:operation/wsdl:(input, output, message)] policy
if (assertions.Count > 0)
{
WsdlNS.MessageBinding wsdlMessageBinding = endpointContext.GetMessageBinding(message);
keyBase = CreateMessageBindingPolicyKey(wsdlMessageBinding, message.Direction);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlMessageBinding);
}
}
foreach (FaultDescription fault in operation.Faults)
{
assertions = policyContext.GetFaultBindingAssertions(fault);
// Add [wsdl:Binding/wsdl:operation/wsdl:fault] policy
if (assertions.Count > 0)
{
WsdlNS.FaultBinding wsdlFaultBinding = endpointContext.GetFaultBinding(fault);
keyBase = CreateFaultBindingPolicyKey(wsdlFaultBinding);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlFaultBinding);
}
}
}
}
示例3: GetBindingElements
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
if (context.Endpoint.Binding == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding");
}
MessageEncodingBindingElement encodingBindingElement = GetBindingElements(context).Find<MessageEncodingBindingElement>();
if (encodingBindingElement != null)
{
System.Type type = encodingBindingElement.GetType();
if (((type != typeof(TextMessageEncodingBindingElement)) && (type != typeof(BinaryMessageEncodingBindingElement))) && (type != typeof(MtomMessageEncodingBindingElement)))
{
return;
}
}
EnsureMessageEncoding(context, encodingBindingElement);
foreach (OperationBinding binding in context.WsdlBinding.Operations)
{
OperationDescription operationDescription = context.GetOperationDescription(binding);
for (int i = 0; i < operationDescription.Messages.Count; i++)
{
MessageDescription message = operationDescription.Messages[i];
MessageBinding messageBinding = context.GetMessageBinding(message);
ImportMessageSoapAction(context.ContractConversionContext, message, messageBinding, i != 0);
}
foreach (FaultDescription description3 in operationDescription.Faults)
{
FaultBinding faultBinding = context.GetFaultBinding(description3);
if (faultBinding != null)
{
ImportFaultSoapAction(context.ContractConversionContext, description3, faultBinding);
}
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:MessageEncodingBindingElementImporter.cs
示例4: AttachPolicy
internal void AttachPolicy(ServiceEndpoint endpoint, WsdlEndpointConversionContext endpointContext, PolicyConversionContext policyContext)
{
string str;
SortedList<string, string> policyKeys = new SortedList<string, string>();
NamingHelper.DoesNameExist doesNameExist = (name, nameCollection) => policyKeys.ContainsKey(name);
System.Web.Services.Description.ServiceDescription serviceDescription = endpointContext.WsdlBinding.ServiceDescription;
ICollection<XmlElement> bindingAssertions = policyContext.GetBindingAssertions();
System.Web.Services.Description.Binding wsdlBinding = endpointContext.WsdlBinding;
if (bindingAssertions.Count > 0)
{
str = NamingHelper.GetUniqueName(CreateBindingPolicyKey(wsdlBinding), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, wsdlBinding);
}
foreach (OperationDescription description2 in endpoint.Contract.Operations)
{
if (WsdlExporter.OperationIsExportable(description2))
{
bindingAssertions = policyContext.GetOperationBindingAssertions(description2);
if (bindingAssertions.Count > 0)
{
OperationBinding operationBinding = endpointContext.GetOperationBinding(description2);
str = NamingHelper.GetUniqueName(CreateOperationBindingPolicyKey(operationBinding), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, operationBinding);
}
foreach (MessageDescription description3 in description2.Messages)
{
bindingAssertions = policyContext.GetMessageBindingAssertions(description3);
if (bindingAssertions.Count > 0)
{
MessageBinding messageBinding = endpointContext.GetMessageBinding(description3);
str = NamingHelper.GetUniqueName(CreateMessageBindingPolicyKey(messageBinding, description3.Direction), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, messageBinding);
}
}
foreach (FaultDescription description4 in description2.Faults)
{
bindingAssertions = policyContext.GetFaultBindingAssertions(description4);
if (bindingAssertions.Count > 0)
{
FaultBinding faultBinding = endpointContext.GetFaultBinding(description4);
str = NamingHelper.GetUniqueName(CreateFaultBindingPolicyKey(faultBinding), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, faultBinding);
}
}
}
}
}