public void Properties() { MessageEncoder t = new TextElement().CreateMessageEncoderFactory().Encoder; MessageEncoder b = new BinaryElement().CreateMessageEncoderFactory().Encoder; MessageEncoder m = new MtomElement().CreateMessageEncoderFactory().Encoder; // TextMessageEncodingBindingElement.WriteEncoding // default value is UTF8. ServiceAssert.AssertMessageEncoder( // Those curly double quotations are smelly, very implementation specific. "application/soap+xml; charset=utf-8", "application/soap+xml", MessageVersion.Default, t, "Text"); ServiceAssert.AssertMessageEncoder( "application/soap+msbin1", "application/soap+msbin1", MessageVersion.Default, b, "Binary"); ServiceAssert.AssertMessageEncoder( "multipart/related; type=\"application/xop+xml\"", "multipart/related", MessageVersion.Default, m, "Mtom"); MessageEncoder t2 = new TextElement( MessageVersion.Soap11WSAddressing10, Encoding.UTF8) .CreateMessageEncoderFactory().Encoder; ServiceAssert.AssertMessageEncoder( // Those curly double quotations are smelly, very implementation specific. "text/xml; charset=utf-8", "text/xml", MessageVersion.Soap11WSAddressing10, t2, "Text2"); }
void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { if (exporter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } ICollection <XmlElement> policyAssertions = context.GetBindingAssertions(); if (TransferModeHelper.IsRequestStreamed(this.TransferMode) || TransferModeHelper.IsResponseStreamed(this.TransferMode)) { policyAssertions.Add(new XmlDocument().CreateElement(TransportPolicyConstants.DotNetFramingPrefix, TransportPolicyConstants.StreamedName, TransportPolicyConstants.DotNetFramingNamespace)); } bool createdNew; MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(context.BindingElements, out createdNew); if (createdNew && encodingBindingElement is IPolicyExportExtension) { encodingBindingElement = new BinaryMessageEncodingBindingElement(); ((IPolicyExportExtension)encodingBindingElement).ExportPolicy(exporter, context); } WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, encodingBindingElement.MessageVersion.Addressing); }
private void CreateBinding() { Collection <BindingElement> bindingElementsInTopDownChannelStackOrder = new Collection <BindingElement>(); BindingElement securityBindingElement = this.config.SecurityManager.GetSecurityBindingElement(); if (securityBindingElement != null) { bindingElementsInTopDownChannelStackOrder.Add(securityBindingElement); } TcpTransportBindingElement item = new TcpTransportBindingElement { MaxReceivedMessageSize = this.config.MaxReceivedMessageSize, MaxBufferPoolSize = this.config.MaxBufferPoolSize, TeredoEnabled = true }; MessageEncodingBindingElement encodingBindingElement = null; if (this.messageHandler != null) { encodingBindingElement = this.messageHandler.EncodingBindingElement; } if (encodingBindingElement == null) { BinaryMessageEncodingBindingElement element4 = new BinaryMessageEncodingBindingElement(); this.config.ReaderQuotas.CopyTo(element4.ReaderQuotas); bindingElementsInTopDownChannelStackOrder.Add(element4); } else { bindingElementsInTopDownChannelStackOrder.Add(encodingBindingElement); } bindingElementsInTopDownChannelStackOrder.Add(item); this.binding = new CustomBinding(bindingElementsInTopDownChannelStackOrder); this.binding.ReceiveTimeout = TimeSpan.MaxValue; }
void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { bool flag; if (exporter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } ICollection <XmlElement> bindingAssertions = context.GetBindingAssertions(); if (TransferModeHelper.IsRequestStreamed(this.TransferMode) || TransferModeHelper.IsResponseStreamed(this.TransferMode)) { bindingAssertions.Add(new XmlDocument().CreateElement("msf", "Streamed", "http://schemas.microsoft.com/ws/2006/05/framing/policy")); } MessageEncodingBindingElement element = this.FindMessageEncodingBindingElement(context.BindingElements, out flag); if (flag && (element is IPolicyExportExtension)) { element = new BinaryMessageEncodingBindingElement(); ((IPolicyExportExtension)element).ExportPolicy(exporter, context); } WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, element.MessageVersion.Addressing); }
public void DefaultValues () { Element el = new Element (); Assert.AreEqual (64, el.MaxReadPoolSize, "#1"); Assert.AreEqual (16, el.MaxWritePoolSize, "#2"); Assert.AreEqual (MessageVersion.Default, el.MessageVersion, "#3"); // FIXME: test ReaderQuotas }
public void DefaultValues() { Element el = new Element(); Assert.AreEqual(64, el.MaxReadPoolSize, "#1"); Assert.AreEqual(16, el.MaxWritePoolSize, "#2"); Assert.AreEqual(MessageVersion.Default, el.MessageVersion, "#3"); // FIXME: test ReaderQuotas }
public void BuildChannelFactory() { CustomBinding cb = new CustomBinding( new HttpTransportBindingElement()); BindingContext ctx = new BindingContext( cb, new BindingParameterCollection()); Element el = new Element(); IChannelFactory <IRequestChannel> cf = el.BuildChannelFactory <IRequestChannel> (ctx); }
public void BuildChannelFactory () { CustomBinding cb = new CustomBinding ( new HttpTransportBindingElement ()); BindingContext ctx = new BindingContext ( cb, new BindingParameterCollection ()); Element el = new Element (); IChannelFactory<IRequestChannel> cf = el.BuildChannelFactory<IRequestChannel> (ctx); }
public void CanBuildChannelFactory () { CustomBinding cb = new CustomBinding ( new HttpTransportBindingElement ()); BindingContext ctx = new BindingContext ( cb, new BindingParameterCollection ()); Element el = new Element (); Assert.IsTrue (el.CanBuildChannelFactory<IRequestChannel> (ctx), "#1"); Assert.IsFalse (el.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#2"); }
private BinaryMessageEncodingBindingElement(BinaryMessageEncodingBindingElement elementToBeCloned) : base(elementToBeCloned) { this.maxReadPoolSize = elementToBeCloned.maxReadPoolSize; this.maxWritePoolSize = elementToBeCloned.maxWritePoolSize; this.readerQuotas = new XmlDictionaryReaderQuotas(); elementToBeCloned.readerQuotas.CopyTo(this.readerQuotas); this.MaxSessionSize = elementToBeCloned.MaxSessionSize; this.BinaryVersion = elementToBeCloned.BinaryVersion; this.messageVersion = elementToBeCloned.messageVersion; }
public override bool IsMatch(BindingElement b) { if (!base.IsMatch(b)) { return(false); } BinaryMessageEncodingBindingElement binary = b as BinaryMessageEncodingBindingElement; if (binary == null) { return(false); } if (_maxReadPoolSize != binary.MaxReadPoolSize) { return(false); } if (_maxWritePoolSize != binary.MaxWritePoolSize) { return(false); } // compare XmlDictionaryReaderQuotas if (_readerQuotas.MaxStringContentLength != binary.ReaderQuotas.MaxStringContentLength) { return(false); } if (_readerQuotas.MaxArrayLength != binary.ReaderQuotas.MaxArrayLength) { return(false); } if (_readerQuotas.MaxBytesPerRead != binary.ReaderQuotas.MaxBytesPerRead) { return(false); } if (_readerQuotas.MaxDepth != binary.ReaderQuotas.MaxDepth) { return(false); } if (_readerQuotas.MaxNameTableCharCount != binary.ReaderQuotas.MaxNameTableCharCount) { return(false); } if (this.MaxSessionSize != binary.MaxSessionSize) { return(false); } if (this.CompressionFormat != binary.CompressionFormat) { return(false); } return(true); }
public void CanBuildChannelFactory() { CustomBinding cb = new CustomBinding( new HttpTransportBindingElement()); BindingContext ctx = new BindingContext( cb, new BindingParameterCollection()); Element el = new Element(); Assert.IsTrue(el.CanBuildChannelFactory <IRequestChannel> (ctx), "#1"); Assert.IsFalse(el.CanBuildChannelFactory <IRequestSessionChannel> (ctx), "#2"); }
private MessageEncodingBindingElement FindMessageEncodingBindingElement(BindingElementCollection bindingElements, out bool createdNew) { createdNew = false; MessageEncodingBindingElement encodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>(); if (encodingBindingElement == null) { createdNew = true; encodingBindingElement = new BinaryMessageEncodingBindingElement(); } return(encodingBindingElement); }
private BinaryMessageEncodingBindingElement(BinaryMessageEncodingBindingElement elementToBeCloned) : base(elementToBeCloned) { _maxReadPoolSize = elementToBeCloned._maxReadPoolSize; _maxWritePoolSize = elementToBeCloned._maxWritePoolSize; _readerQuotas = new XmlDictionaryReaderQuotas(); elementToBeCloned._readerQuotas.CopyTo(_readerQuotas); this.MaxSessionSize = elementToBeCloned.MaxSessionSize; this.BinaryVersion = elementToBeCloned.BinaryVersion; _messageVersion = elementToBeCloned._messageVersion; this.CompressionFormat = elementToBeCloned.CompressionFormat; _maxReceivedMessageSize = elementToBeCloned._maxReceivedMessageSize; }
internal override bool IsMatch(BindingElement b) { if (!base.IsMatch(b)) { return(false); } BinaryMessageEncodingBindingElement element = b as BinaryMessageEncodingBindingElement; if (element == null) { return(false); } if (this.maxReadPoolSize != element.MaxReadPoolSize) { return(false); } if (this.maxWritePoolSize != element.MaxWritePoolSize) { return(false); } if (this.readerQuotas.MaxStringContentLength != element.ReaderQuotas.MaxStringContentLength) { return(false); } if (this.readerQuotas.MaxArrayLength != element.ReaderQuotas.MaxArrayLength) { return(false); } if (this.readerQuotas.MaxBytesPerRead != element.ReaderQuotas.MaxBytesPerRead) { return(false); } if (this.readerQuotas.MaxDepth != element.ReaderQuotas.MaxDepth) { return(false); } if (this.readerQuotas.MaxNameTableCharCount != element.ReaderQuotas.MaxNameTableCharCount) { return(false); } if (this.MaxSessionSize != element.MaxSessionSize) { return(false); } return(true); }
internal PeerChannelFactory(PeerTransportBindingElement bindingElement, BindingContext context, PeerResolver peerResolver) : base(bindingElement, context) { this.listenIPAddress = bindingElement.ListenIPAddress; this.port = bindingElement.Port; this.resolver = peerResolver; this.readerQuotas = new XmlDictionaryReaderQuotas(); BinaryMessageEncodingBindingElement element = context.Binding.Elements.Find <BinaryMessageEncodingBindingElement>(); if (element != null) { element.ReaderQuotas.CopyTo(this.readerQuotas); } else { EncoderDefaults.ReaderQuotas.CopyTo(this.readerQuotas); } this.securityManager = PeerSecurityManager.Create(bindingElement.Security, context, this.readerQuotas); this.securityCapabilities = bindingElement.GetProperty <ISecurityCapabilities>(context); }
// Create the binding using user specified config. The stacking is // BinaryMessageEncoder/TCP void CreateBinding() { Collection <BindingElement> bindingElements = new Collection <BindingElement>(); BindingElement security = this.config.SecurityManager.GetSecurityBindingElement(); if (security != null) { bindingElements.Add(security); } TcpTransportBindingElement transport = new TcpTransportBindingElement(); transport.MaxReceivedMessageSize = this.config.MaxReceivedMessageSize; transport.MaxBufferPoolSize = this.config.MaxBufferPoolSize; transport.TeredoEnabled = true; MessageEncodingBindingElement encoder = null; if (messageHandler != null) { encoder = messageHandler.EncodingBindingElement; } if (encoder == null) { BinaryMessageEncodingBindingElement bencoder = new BinaryMessageEncodingBindingElement(); this.config.ReaderQuotas.CopyTo(bencoder.ReaderQuotas); bindingElements.Add(bencoder); } else { bindingElements.Add(encoder); } bindingElements.Add(transport); this.binding = new CustomBinding(bindingElements); this.binding.ReceiveTimeout = TimeSpan.MaxValue; }
private BinaryMessageEncodingBindingElement( BinaryMessageEncodingBindingElement other) { throw new NotImplementedException(); }
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); }
public BinaryMessageEncoderFactory( BinaryMessageEncodingBindingElement owner) { this.owner = owner; encoder = new BinaryMessageEncoder(this, false); }