internal static WS.Soap12Binding GetTcpSoapBinding(WS.Binding binding) { WS.Soap12Binding soap = null; foreach (var extension in binding.Extensions) { var check = extension as WS.Soap12Binding; if (check != null) { soap = check; break; } } if (soap == null) { return(null); } if (soap.Transport != TcpTransport) { return(null); } if (soap.Style != WS.SoapBindingStyle.Document) { return(null); } return(soap); }
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { var soap_binding = new WS.Soap12Binding(); soap_binding.Transport = "http://schemas.microsoft.com/soap/tcp"; soap_binding.Style = WS.SoapBindingStyle.Document; context.WsdlBinding.Extensions.Add(soap_binding); var address = context.Endpoint.Address; var uri = address.Uri.AbsoluteUri; var soap_address = new WS.Soap12AddressBinding(); soap_address.Location = uri; context.WsdlPort.Extensions.Add(soap_address); var doc = new XmlDocument(); var endpoint_ref = doc.CreateElement( "EndpointReference", AddressingVersion.WSAddressing10.Namespace); var endpoint_addr = doc.CreateElement( "Address", AddressingVersion.WSAddressing10.Namespace); endpoint_addr.InnerText = uri; endpoint_ref.AppendChild(endpoint_addr); context.WsdlPort.Extensions.Add(endpoint_ref); }
bool ImportTcpPolicy(MetadataImporter importer, PolicyConversionContext context, WS.Soap12Binding soap) { var assertions = context.GetBindingAssertions(); var tcpTransport = new TcpTransportBindingElement(); var transportPolicy = PolicyImportHelper.GetTransportBindingPolicy(assertions); if (transportPolicy != null) { if (!ImportTcpTransport(importer, context, transportPolicy)) { return(false); } if (!ImportTransport(importer, tcpTransport, transportPolicy)) { return(false); } } var streamed = PolicyImportHelper.GetStreamedMessageFramingPolicy(assertions); if (streamed != null) { tcpTransport.TransferMode = TransferMode.Streamed; } context.BindingElements.Add(tcpTransport); return(true); }
protected override SoapBinding CreateSoapBinding(SoapBindingStyle style) { Soap12Binding soapBinding = new Soap12Binding(); soapBinding.Transport = Soap12Binding.HttpTransport; soapBinding.Style = style; return(soapBinding); }
protected override bool IsBindingSupported() { Soap12Binding binding = (Soap12Binding)base.Binding.Extensions.Find(typeof(Soap12Binding)); if (binding == null) { return(false); } if (base.GetTransport(binding.Transport) == null) { base.UnsupportedBindingWarning(Res.GetString("ThereIsNoSoapTransportImporterThatUnderstands1", new object[] { binding.Transport })); return(false); } return(true); }
// static WsdlNS.SoapBinding CreateSoapBinding(EnvelopeVersion version, WsdlNS.Binding wsdlBinding) { WsdlNS.SoapBinding soapBinding = null; if (version == EnvelopeVersion.Soap12) { soapBinding = new WsdlNS.Soap12Binding(); } else if (version == EnvelopeVersion.Soap11) { soapBinding = new WsdlNS.SoapBinding(); } Fx.Assert(soapBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class"); wsdlBinding.Extensions.Add(soapBinding); return(soapBinding); }
protected override bool IsBindingSupported() { Soap12Binding soapBinding = (Soap12Binding)Binding.Extensions.Find(typeof(Soap12Binding)); if (soapBinding == null) { return(false); } if (GetTransport(soapBinding.Transport) == null) { UnsupportedBindingWarning(Res.GetString(Res.ThereIsNoSoapTransportImporterThatUnderstands1, soapBinding.Transport)); return(false); } return(true); }
public static void NetTcpBinding( TestContext context, MetadataSet doc, SecurityMode security, bool reliableSession, TransferMode transferMode, TestLabel label) { label.EnterScope("netTcpBinding"); var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata; label.EnterScope("wsdl"); label.EnterScope("bindings"); Assert.That(sd.Bindings.Count, Is.EqualTo(1), label.Get()); var binding = sd.Bindings [0]; Assert.That(binding.ExtensibleAttributes, Is.Null, label.Get()); Assert.That(binding.Extensions, Is.Not.Null, label.Get()); WS.Soap12Binding soap = null; XmlElement xml = null; foreach (var ext in binding.Extensions) { if (ext is WS.Soap12Binding) { soap = (WS.Soap12Binding)ext; } else if (ext is XmlElement) { xml = (XmlElement)ext; } } CheckSoapBinding(soap, "http://schemas.microsoft.com/soap/tcp", label); label.EnterScope("policy-xml"); Assert.That(xml, Is.Not.Null, label.Get()); var assertions = AssertPolicy(sd, xml, label); Assert.That(assertions, Is.Not.Null, label.Get()); AssertPolicy(assertions, BinaryEncodingQName, label); AssertPolicy(assertions, UsingAddressingQName, label); if (transferMode == TransferMode.Streamed) { AssertPolicy(assertions, StreamedTransferQName, label); } switch (security) { case SecurityMode.Message: AssertPolicy(assertions, SymmetricBindingQName, label); AssertPolicy(assertions, Wss11QName, label); AssertPolicy(assertions, Trust10QName, label); break; case SecurityMode.Transport: AssertPolicy(assertions, TransportBindingQName, label); break; case SecurityMode.TransportWithMessageCredential: AssertPolicy(assertions, TransportBindingQName, label); AssertPolicy(assertions, EndorsingSupportingQName, label); AssertPolicy(assertions, Wss11QName, label); AssertPolicy(assertions, Trust10QName, label); break; default: break; } if (reliableSession) { AssertPolicy(assertions, ReliableSessionQName, label); } Assert.That(assertions.Count, Is.EqualTo(0), label.Get()); label.LeaveScope(); label.EnterScope("services"); Assert.That(sd.Services, Is.Not.Null, label.Get()); Assert.That(sd.Services.Count, Is.EqualTo(1), label.Get()); var service = sd.Services [0]; Assert.That(service.Ports, Is.Not.Null, label.Get()); Assert.That(service.Ports.Count, Is.EqualTo(1), label.Get()); var port = service.Ports [0]; label.EnterScope("port"); Assert.That(port.Extensions, Is.Not.Null, label.Get()); Assert.That(port.Extensions.Count, Is.EqualTo(2), label.Get()); WS.Soap12AddressBinding soap_addr_binding = null; XmlElement port_xml = null; foreach (var extension in port.Extensions) { if (extension is WS.Soap12AddressBinding) { soap_addr_binding = (WS.Soap12AddressBinding)extension; } else if (extension is XmlElement) { port_xml = (XmlElement)extension; } else { Assert.Fail(label.Get()); } } Assert.That(soap_addr_binding, Is.Not.Null, label.Get()); Assert.That(port_xml, Is.Not.Null, label.Get()); Assert.That(port_xml.NamespaceURI, Is.EqualTo(Wsa10Namespace), label.Get()); Assert.That(port_xml.LocalName, Is.EqualTo("EndpointReference"), label.Get()); label.LeaveScope(); label.LeaveScope(); label.LeaveScope(); // wsdl var importer = new WsdlImporter(doc); label.EnterScope("bindings"); var bindings = importer.ImportAllBindings(); CheckImportErrors(importer, label); Assert.That(bindings, Is.Not.Null, label.Get()); Assert.That(bindings.Count, Is.EqualTo(1), label.Get()); CheckNetTcpBinding( bindings [0], security, reliableSession, transferMode, label); label.LeaveScope(); label.EnterScope("endpoints"); var endpoints = importer.ImportAllEndpoints(); CheckImportErrors(importer, label); Assert.That(endpoints, Is.Not.Null, label.Get()); Assert.That(endpoints.Count, Is.EqualTo(1), label.Get()); CheckEndpoint(endpoints [0], MetadataSamples.NetTcpUri, label); label.LeaveScope(); label.LeaveScope(); }
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); }
private static object GetSoapBinding(System.ServiceModel.Channels.Binding binding) { if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap11) { SoapBinding soapBinding = new SoapBinding(); soapBinding.Transport = GetTransport(binding); soapBinding.Style = SoapBindingStyle.Document; return soapBinding; } else if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap12) { Soap12Binding soapBinding = new Soap12Binding(); soapBinding.Transport = GetTransport(binding); soapBinding.Style = SoapBindingStyle.Document; return soapBinding; } return null; }
private void Write84_Soap12Binding(string n, string ns, Soap12Binding o, bool isNullable, bool needType) { if (o == null) { if (isNullable) { base.WriteNullTagLiteral(n, ns); } } else { if (!needType && !(o.GetType() == typeof(Soap12Binding))) { throw base.CreateUnknownTypeException(o); } base.WriteStartElement(n, ns, o, false, null); if (needType) { base.WriteXsiType("Soap12Binding", "http://schemas.xmlsoap.org/wsdl/soap12/"); } if (o.Required) { base.WriteAttribute("required", "http://schemas.xmlsoap.org/wsdl/", XmlConvert.ToString(o.Required)); } base.WriteAttribute("transport", "", o.Transport); if (o.Style != SoapBindingStyle.Document) { base.WriteAttribute("style", "", this.Write82_SoapBindingStyle(o.Style)); } base.WriteEndElement(o); } }
protected override SoapBinding CreateSoapBinding(SoapBindingStyle style) { Soap12Binding soapBinding = new Soap12Binding(); soapBinding.Transport = Soap12Binding.HttpTransport; soapBinding.Style = style; return soapBinding; }