Пример #1
0
        public void ValidateCustomBasicHttpBindingWithTransportSecurity()
        {
            var wca = new WcfCustomAdapter.Outbound <BasicHttpBindingElement>(
                a => {
                a.Address = new EndpointAddress("https://services.stateless.be/soap/default");
                a.Binding.Security.Mode = BasicHttpSecurityMode.Transport;
                a.Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
                a.EndpointBehaviors = new[] {
                    new ClientCredentialsElement {
                        ClientCertificate =
                        {
                            FindValue     = "*.stateless.be",
                            StoreLocation = StoreLocation.LocalMachine,
                            StoreName     = StoreName.My,
                            X509FindType  = X509FindType.FindBySubjectName
                        }
                    }
                };
                a.Identity = EndpointIdentityFactory.CreateCertificateIdentity(
                    StoreLocation.LocalMachine,
                    StoreName.TrustedPeople,
                    X509FindType.FindBySubjectDistinguishedName,
                    "*.services.party.be");
            });

            Assert.That(() => ((ISupportValidation)wca).Validate(), Throws.Nothing);
        }
Пример #2
0
        public void ValidateCustomBinding()
        {
            var wca = new WcfCustomAdapter.Outbound <CustomBindingElement>(
                a => {
                a.Address = new EndpointAddress("https://localhost/biztalk.factory/service.svc");
                a.Binding.Add(
                    new MtomMessageEncodingElement {
                    MessageVersion = MessageVersion.Soap11
                },
                    new HttpsTransportElement {
                    RequireClientCertificate = true
                });
            });

            Assert.That(() => ((ISupportValidation)wca).Validate(), Throws.Nothing);
        }
Пример #3
0
        public void ValidateDoesNotThrow()
        {
            var wca = new WcfCustomAdapter.Outbound <NetTcpBindingElement>(
                a => {
                const int tenMegaBytes = 1024 * 1024 * 10;
                a.Address = new EndpointAddress("net.tcp://localhost/biztalk.factory/service.svc");
                a.Binding.MaxReceivedMessageSize              = tenMegaBytes;
                a.Binding.ReaderQuotas.MaxArrayLength         = tenMegaBytes;
                a.Binding.ReaderQuotas.MaxStringContentLength = tenMegaBytes;
                a.Binding.Security.Mode = SecurityMode.Transport;
                a.Binding.Security.Transport.ProtectionLevel      = ProtectionLevel.Sign;
                a.Binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                a.StaticAction = "http://services.biztalk.net/mail/2011/11/IMailService/SendMessage";
            });

            Assert.That(() => ((ISupportValidation)wca).Validate(), Throws.Nothing);
        }
        public void SerializeCustomBindingToXml()
        {
            Skip.IfNot(BizTalkServerGroup.IsConfigured);

            var wca = new WcfCustomAdapter.Outbound <CustomBindingElement>(
                a => {
                a.OpenTimeout = TimeSpan.FromMinutes(33);
                a.SendTimeout = TimeSpan.FromMinutes(2);
                a.Binding.Add(
                    new MtomMessageEncodingElement {
                    MessageVersion = MessageVersion.Soap11,
                    ReaderQuotas   = { MaxStringContentLength = 7340032 }
                },
                    new HttpsTransportElement {
                    MaxReceivedMessageSize   = 7340032,
                    MaxBufferSize            = 7340032,
                    UseDefaultWebProxy       = false,
                    RequireClientCertificate = true
                });
            });
            var xml = wca.GetAdapterBindingInfoSerializer().Serialize();

            xml.Should().Be(
                "<CustomProps>" +
                "<BindingType vt=\"8\">customBinding</BindingType>" +
                "<BindingConfiguration vt=\"8\">" + (
                    "&lt;binding name=\"customDslBinding\" openTimeout=\"00:33:00\" sendTimeout=\"00:02:00\"&gt;" +
                    "&lt;mtomMessageEncoding messageVersion=\"Soap11\"&gt;" +
                    "&lt;readerQuotas maxStringContentLength=\"7340032\" /&gt;" +
                    "&lt;/mtomMessageEncoding&gt;" +
                    "&lt;httpsTransport maxReceivedMessageSize=\"7340032\" maxBufferSize=\"7340032\" useDefaultWebProxy=\"false\" requireClientCertificate=\"true\" /&gt;" +
                    "&lt;/binding&gt;") +
                "</BindingConfiguration>" +
                "<EndpointBehaviorConfiguration vt=\"8\">&lt;behavior name=\"EndpointBehavior\" /&gt;</EndpointBehaviorConfiguration>" +
                "<UseSSO vt=\"11\">0</UseSSO>" +
                "<InboundBodyLocation vt=\"8\">UseBodyElement</InboundBodyLocation>" +
                "<InboundNodeEncoding vt=\"8\">Xml</InboundNodeEncoding>" +
                "<OutboundBodyLocation vt=\"8\">UseBodyElement</OutboundBodyLocation>" +
                "<OutboundXmlTemplate vt=\"8\">&lt;bts-msg-body xmlns=\"http://www.microsoft.com/schemas/bts2007\" encoding=\"xml\"/&gt;</OutboundXmlTemplate>" +
                "<PropagateFaultMessage vt=\"11\">-1</PropagateFaultMessage>" +
                "<EnableTransaction vt=\"11\">0</EnableTransaction>" +
                "<IsolationLevel vt=\"8\">Serializable</IsolationLevel>" +
                "</CustomProps>");
        }
Пример #5
0
        public void SerializeToXml()
        {
            var wca = new WcfCustomAdapter.Outbound <NetTcpBindingElement>(
                a => {
                const int tenMegaBytes = 1024 * 1024 * 10;
                a.Address = new EndpointAddress("net.tcp://localhost/biztalk.factory/service.svc");
                a.Binding.MaxReceivedMessageSize              = tenMegaBytes;
                a.Binding.ReaderQuotas.MaxArrayLength         = tenMegaBytes;
                a.Binding.ReaderQuotas.MaxStringContentLength = tenMegaBytes;
                a.Binding.Security.Mode = SecurityMode.Transport;
                a.Binding.Security.Transport.ProtectionLevel      = ProtectionLevel.Sign;
                a.Binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                a.StaticAction = "http://services.biztalk.net/mail/2011/11/IMailService/SendMessage";
            });
            var xml = ((IAdapterBindingSerializerFactory)wca).GetAdapterBindingSerializer().Serialize();

            Assert.That(
                xml,
                Is.EqualTo(
                    "<CustomProps>" +
                    "<BindingType vt=\"8\">netTcpBinding</BindingType>" +
                    "<BindingConfiguration vt=\"8\">" +
                    "&lt;binding name=\"netTcpBinding\" maxReceivedMessageSize=\"10485760\"&gt;" +
                    "&lt;readerQuotas maxStringContentLength=\"10485760\" maxArrayLength=\"10485760\" /&gt;" +
                    "&lt;security&gt;&lt;transport protectionLevel=\"Sign\" /&gt;&lt;/security&gt;" +
                    "&lt;/binding&gt;" +
                    "</BindingConfiguration>" +
                    "<EndpointBehaviorConfiguration vt=\"8\">&lt;behavior name=\"EndpointBehavior\" /&gt;" + "</EndpointBehaviorConfiguration>" +
                    "<StaticAction vt=\"8\">http://services.biztalk.net/mail/2011/11/IMailService/SendMessage" +
                    "</StaticAction><UseSSO vt=\"11\">0</UseSSO>" +
                    "<InboundBodyLocation vt=\"8\">UseBodyElement</InboundBodyLocation>" +
                    "<InboundNodeEncoding vt=\"8\">Xml</InboundNodeEncoding>" +
                    "<OutboundBodyLocation vt=\"8\">UseBodyElement</OutboundBodyLocation>" +
                    "<OutboundXmlTemplate vt=\"8\">&lt;bts-msg-body xmlns=\"http://www.microsoft.com/schemas/bts2007\" encoding=\"xml\"/&gt;</OutboundXmlTemplate>" +
                    "<PropagateFaultMessage vt=\"11\">-1</PropagateFaultMessage>" +
                    "<EnableTransaction vt=\"11\">0</EnableTransaction>" +
                    "<IsolationLevel vt=\"8\">Serializable</IsolationLevel>" +
                    "</CustomProps>"));
        }