void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context != null && context.WsdlBinding != null && ContainsHttpBindingExtension(context.WsdlBinding)) { httpBindingContracts.Add(context.ContractConversionContext.Contract); } }
private void CallExportEndpoint(WsdlEndpointConversionContext endpointContext) { foreach (IWsdlExportExtension extension in endpointContext.ExportExtensions) { this.CallExtension(endpointContext, extension); } }
ServiceEndpoint ImportBinding(WSBinding binding, WsdlContractConversionContext contract_context) { BeforeImport(); var sep = new ServiceEndpoint(contract_context.Contract); var custom = new CustomBinding(); custom.Name = binding.Name; custom.Namespace = binding.ServiceDescription.TargetNamespace; sep.Binding = custom; try { ImportPolicy(binding, sep); } catch (Exception ex) { // FIXME: Policy import is still experimental. AddWarning("Exception while trying to import policy for " + "binding `{0}': {1}", binding.Name, ex.Message); } var endpoint_context = new WsdlEndpointConversionContext( contract_context, sep, null, binding); foreach (IWsdlImportExtension extension in wsdl_extensions) { extension.ImportEndpoint(this, endpoint_context); } return(sep); }
public void ExportEndpoint( WsdlExporter exporter, WsdlEndpointConversionContext context ) { }
internal MessageBindingExporter(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext) { this.endpointContext = endpointContext; this.exportedMessages = (MessageContractExporter.MessageExportContext)exporter.State[typeof(MessageContractExporter.MessageExportContext)]; this.soapVersion = SoapHelper.GetSoapVersion(endpointContext.WsdlBinding); this.exporter = exporter; }
static internal void ImportMessageBinding(WsdlImporter importer, WsdlEndpointConversionContext endpointContext, Type schemaImporterType) { // All the work is done in ImportMessageContract call bool isReferencedContract = IsReferencedContract(importer, endpointContext); MarkSoapExtensionsAsHandled(endpointContext.WsdlBinding); foreach (WsdlNS.OperationBinding wsdlOperationBinding in endpointContext.WsdlBinding.Operations) { OperationDescription operation = endpointContext.GetOperationDescription(wsdlOperationBinding); if (isReferencedContract || OperationHasBeenHandled(operation)) { MarkSoapExtensionsAsHandled(wsdlOperationBinding); if (wsdlOperationBinding.Input != null) { MarkSoapExtensionsAsHandled(wsdlOperationBinding.Input); } if (wsdlOperationBinding.Output != null) { MarkSoapExtensionsAsHandled(wsdlOperationBinding.Output); } foreach (WsdlNS.MessageBinding wsdlMessageBinding in wsdlOperationBinding.Faults) { MarkSoapExtensionsAsHandled(wsdlMessageBinding); } } } }
internal static void SetSoapVersion(WsdlEndpointConversionContext endpointContext, WsdlExporter exporter, EnvelopeVersion version) { SetSoapVersionState(endpointContext.WsdlBinding, exporter, version); //Convert all SOAP extensions to the right version. if (endpointContext.WsdlPort != null) { SoapConverter.ConvertExtensions(endpointContext.WsdlPort.Extensions, version, SoapConverter.ConvertSoapAddressBinding); } SoapConverter.ConvertExtensions(endpointContext.WsdlBinding.Extensions, version, SoapConverter.ConvertSoapBinding); foreach (WsdlNS.OperationBinding operationBinding in endpointContext.WsdlBinding.Operations) { SoapConverter.ConvertExtensions(operationBinding.Extensions, version, SoapConverter.ConvertSoapOperationBinding); //Messages { if (operationBinding.Input != null) { SoapConverter.ConvertExtensions(operationBinding.Input.Extensions, version, SoapConverter.ConvertSoapMessageBinding); } if (operationBinding.Output != null) { SoapConverter.ConvertExtensions(operationBinding.Output.Extensions, version, SoapConverter.ConvertSoapMessageBinding); } foreach (WsdlNS.MessageBinding faultBinding in operationBinding.Faults) { SoapConverter.ConvertExtensions(faultBinding.Extensions, version, SoapConverter.ConvertSoapMessageBinding); } } } }
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"); } #pragma warning suppress 56506 // [....], CustomBinding.Elements never be null TransportBindingElement transportBindingElement = GetBindingElements(context).Find<TransportBindingElement>(); bool transportHandledExternaly = (transportBindingElement != null) && !StateHelper.IsRegisteredTransportBindingElement(importer, context); if (transportHandledExternaly) return; #pragma warning suppress 56506 // [....], these properties cannot be null in this context WsdlNS.SoapBinding soapBinding = (WsdlNS.SoapBinding)context.WsdlBinding.Extensions.Find(typeof(WsdlNS.SoapBinding)); if (soapBinding != null && transportBindingElement == null) { CreateLegacyTransportBindingElement(importer, soapBinding, context); } // Try to import WS-Addressing address from the port if (context.WsdlPort != null) { ImportAddress(context, transportBindingElement); } }
internal static void SetSoapVersion(WsdlEndpointConversionContext endpointContext, WsdlExporter exporter, EnvelopeVersion version) { SetSoapVersionState(endpointContext.WsdlBinding, exporter, version); if (endpointContext.WsdlPort != null) { SoapConverter.ConvertExtensions(endpointContext.WsdlPort.Extensions, version, new SoapConverter.ConvertExtension(SoapConverter.ConvertSoapAddressBinding)); } SoapConverter.ConvertExtensions(endpointContext.WsdlBinding.Extensions, version, new SoapConverter.ConvertExtension(SoapConverter.ConvertSoapBinding)); foreach (OperationBinding binding in endpointContext.WsdlBinding.Operations) { SoapConverter.ConvertExtensions(binding.Extensions, version, new SoapConverter.ConvertExtension(SoapConverter.ConvertSoapOperationBinding)); if (binding.Input != null) { SoapConverter.ConvertExtensions(binding.Input.Extensions, version, new SoapConverter.ConvertExtension(SoapConverter.ConvertSoapMessageBinding)); } if (binding.Output != null) { SoapConverter.ConvertExtensions(binding.Output.Extensions, version, new SoapConverter.ConvertExtension(SoapConverter.ConvertSoapMessageBinding)); } foreach (MessageBinding binding2 in binding.Faults) { SoapConverter.ConvertExtensions(binding2.Extensions, version, new SoapConverter.ConvertExtension(SoapConverter.ConvertSoapMessageBinding)); } } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext) { if (endpointContext == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endpointContext")); MessageContractImporter.ImportMessageBinding(importer, endpointContext, typeof(MessageContractImporter.XmlSerializerSchemaImporter)); }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { for (int i = 0; i < context.WsdlBinding.Extensions.Count; i ++) { if (context.WsdlBinding.Extensions [i] is SoapBinding) { SoapBinding transport = context.WsdlBinding.Extensions [i] as SoapBinding; if (transport.Transport != SoapBinding.HttpTransport) //FIXME: not http return; if (! (context.Endpoint.Binding is CustomBinding)) //FIXME: throw new Exception (); ((CustomBinding) context.Endpoint.Binding).Elements.Add (new HttpTransportBindingElement ()); //((CustomBinding) context.Endpoint.Binding).Scheme = "http"; for (int j = 0; j < context.WsdlPort.Extensions.Count; j ++) { SoapAddressBinding address = context.WsdlPort.Extensions [j] as SoapAddressBinding; if (address == null) continue; context.Endpoint.Address = new EndpointAddress (address.Location); context.Endpoint.ListenUri = new Uri (address.Location); } break; } } }
internal static WsdlNS.SoapHeaderBinding CreateSoapHeaderBinding(WsdlEndpointConversionContext endpointContext, WsdlNS.MessageBinding wsdlMessageBinding) { EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding); WsdlNS.SoapHeaderBinding soapHeaderBinding = CreateSoapHeaderBinding(version, wsdlMessageBinding); return(soapHeaderBinding); }
public void ImportEndpoint (WsdlImporter importer, WsdlEndpointConversionContext context) { // Only import the binding, not the endpoint. if (context.WsdlPort == null) return; DoImportEndpoint (context); }
bool DoImportEndpoint (WsdlEndpointConversionContext context) { if (ImportBasicHttpEndpoint (context)) return true; if (ImportNetTcpEndpoint (context)) return true; return false; }
internal static void CreateSoapFaultBinding(string name, WsdlEndpointConversionContext endpointContext, FaultBinding wsdlFaultBinding, bool isEncoded) { XmlElement extension = CreateSoapFaultBinding(GetSoapVersion(endpointContext.WsdlBinding)); extension.Attributes.Append(CreateLocalAttribute("name", name)); extension.Attributes.Append(CreateLocalAttribute("use", isEncoded ? "encoded" : "literal")); wsdlFaultBinding.Extensions.Add(extension); }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext) { if (endpointContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endpointContext")); } MessageContractImporter.ImportMessageBinding(importer, endpointContext, typeof(MessageContractImporter.XmlSerializerSchemaImporter)); }
void IWsdlImportExtension.ImportEndpoint (WsdlImporter importer, WsdlEndpointConversionContext context) { if (!Enabled) return; impl.ImportEndpoint (importer, context); }
private static void CreateLegacyTransportBindingElement(WsdlImporter importer, SoapBinding soapBinding, WsdlEndpointConversionContext context) { TransportBindingElement item = CreateTransportBindingElements(soapBinding.Transport, null); if (item != null) { ConvertToCustomBinding(context).Elements.Add(item); StateHelper.RegisterTransportBindingElement(importer, context); } }
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { if (SingleFile) SingleFileExporter.ExportEndpoint(exporter); if (Location != null) { LocationOverrideExporter.ExportEndpoint(exporter, context, Location); } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (!Enabled) { return; } impl.ImportEndpoint(importer, context); }
static CustomBinding ConvertToCustomBinding(WsdlEndpointConversionContext context) { CustomBinding customBinding = context.Endpoint.Binding as CustomBinding; if (customBinding == null) { customBinding = new CustomBinding(context.Endpoint.Binding); context.Endpoint.Binding = customBinding; } return customBinding; }
private static CustomBinding ConvertToCustomBinding(WsdlEndpointConversionContext context) { CustomBinding binding = context.Endpoint.Binding as CustomBinding; if (binding == null) { binding = new CustomBinding(context.Endpoint.Binding); context.Endpoint.Binding = binding; } return binding; }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext) { if (endpointContext == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); #pragma warning suppress 56506 // [....], endpointContext.Endpoint is never null if (endpointContext.Endpoint.Binding == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext.Binding"); if (endpointContext.Endpoint.Binding is CustomBinding) { BindingElementCollection elements = ((CustomBinding)endpointContext.Endpoint.Binding).Elements; Binding binding; TransportBindingElement transport = elements.Find<TransportBindingElement>(); if (transport is HttpTransportBindingElement) { if (WSHttpBindingBase.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } else if (WSDualHttpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } else if (BasicHttpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } else if (NetHttpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } } else if (transport is MsmqTransportBindingElement && NetMsmqBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } else if (transport is NamedPipeTransportBindingElement && NetNamedPipeBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } #pragma warning disable 0618 else if (transport is PeerTransportBindingElement && NetPeerTcpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } #pragma warning restore 0618 else if (transport is TcpTransportBindingElement && NetTcpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } } }
static WsdlNS.SoapBodyBinding GetSoapBodyBinding(WsdlEndpointConversionContext endpointContext, WsdlNS.MessageBinding wsdlMessageBinding) { foreach (object o in wsdlMessageBinding.Extensions) { if (o is WsdlNS.SoapBodyBinding) { return((WsdlNS.SoapBodyBinding)o); } } return(null); }
private static SoapBinding GetSoapBinding(WsdlEndpointConversionContext endpointContext) { foreach (object obj2 in endpointContext.WsdlBinding.Extensions) { if (obj2 is SoapBinding) { return((SoapBinding)obj2); } } return(null); }
static WsdlNS.SoapBinding GetSoapBinding(WsdlEndpointConversionContext endpointContext) { foreach (object o in endpointContext.WsdlBinding.Extensions) { if (o is WsdlNS.SoapBinding) { return((WsdlNS.SoapBinding)o); } } return(null); }
private static SoapOperationBinding GetSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation) { foreach (object obj2 in endpointContext.GetOperationBinding(operation).Extensions) { if (obj2 is SoapOperationBinding) { return((SoapOperationBinding)obj2); } } return(null); }
private static SoapBodyBinding GetSoapBodyBinding(WsdlEndpointConversionContext endpointContext, MessageBinding wsdlMessageBinding) { foreach (object obj2 in wsdlMessageBinding.Extensions) { if (obj2 is SoapBodyBinding) { return((SoapBodyBinding)obj2); } } return(null); }
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext) { if (exporter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); } if (endpointContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); } MessageContractExporter.ExportMessageBinding(exporter, endpointContext, typeof(XmlSerializerMessageContractExporter), this.reflector.Operation); }
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext) { if (exporter == null) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); } if (endpointContext == null) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); } MessageContractExporter.ExportMessageBinding(exporter, endpointContext, typeof(DataContractSerializerMessageContractExporter), this.operation); }
public ServiceEndpoint ImportEndpoint(Port wsdlPort) { foreach (IWsdlImportExtension extension in wsdl_extensions) { extension.BeforeImport(wsdl_documents, xmlschemas, policies); } //Get the corresponding contract //via the PortType WSBinding wsb = wsdlPort.Service.ServiceDescription.Bindings [wsdlPort.Binding.Name]; if (wsb == null) { //FIXME throw new Exception(String.Format("Binding named {0} not found.", wsdlPort.Binding.Name)); } SMBinding binding = ImportBinding(wsb); PortType port_type = null; foreach (WSServiceDescription sd in wsdl_documents) { port_type = sd.PortTypes [wsb.Type.Name]; if (port_type != null) { break; } } if (port_type == null) { //FIXME throw new Exception(String.Format("PortType named {0} not found.", wsb.Type.Name)); } ContractDescription contract = ImportContract(port_type); ServiceEndpoint sep = new ServiceEndpoint(contract); sep.Binding = binding; WsdlContractConversionContext contract_context = new WsdlContractConversionContext(contract, port_type); WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext( contract_context, sep, wsdlPort, wsb); foreach (IWsdlImportExtension extension in wsdl_extensions) { extension.ImportEndpoint(this, endpoint_context); } return(sep); }
internal WsdlEndpointConversionContext(WsdlEndpointConversionContext bindingContext, ServiceEndpoint endpoint, Port wsdlport) { this.endpoint = endpoint; this.wsdlBinding = bindingContext.WsdlBinding; this.wsdlPort = wsdlport; this.contractContext = bindingContext.contractContext; this.wsdlOperationBindings = bindingContext.wsdlOperationBindings; this.operationDescriptionBindings = bindingContext.operationDescriptionBindings; this.wsdlMessageBindings = bindingContext.wsdlMessageBindings; this.messageDescriptionBindings = bindingContext.messageDescriptionBindings; this.wsdlFaultBindings = bindingContext.wsdlFaultBindings; this.faultDescriptionBindings = bindingContext.faultDescriptionBindings; }
static WsdlNS.SoapOperationBinding GetSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation) { WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation); foreach (object o in wsdlOperationBinding.Extensions) { if (o is WsdlNS.SoapOperationBinding) { return((WsdlNS.SoapOperationBinding)o); } } return(null); }
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); } } } }
internal WsdlEndpointConversionContext(WsdlEndpointConversionContext bindingContext, ServiceEndpoint endpoint, WsdlNS.Port wsdlport) { _endpoint = endpoint; _wsdlBinding = bindingContext.WsdlBinding; _wsdlPort = wsdlport; _contractContext = bindingContext._contractContext; _wsdlOperationBindings = bindingContext._wsdlOperationBindings; _operationDescriptionBindings = bindingContext._operationDescriptionBindings; _wsdlMessageBindings = bindingContext._wsdlMessageBindings; _messageDescriptionBindings = bindingContext._messageDescriptionBindings; _wsdlFaultBindings = bindingContext._wsdlFaultBindings; _faultDescriptionBindings = bindingContext._faultDescriptionBindings; }
internal static SoapBinding GetOrCreateSoapBinding(WsdlEndpointConversionContext endpointContext, WsdlExporter exporter) { if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None) { return(null); } SoapBinding soapBinding = GetSoapBinding(endpointContext); if (soapBinding != null) { return(soapBinding); } return(CreateSoapBinding(GetSoapVersion(endpointContext.WsdlBinding), endpointContext.WsdlBinding)); }
void ImportEndpoint(Port port, WSBinding wsb, ServiceEndpoint sep, bool throwOnError) { BeforeImport(); var port_type = GetPortTypeFromBinding(wsb); var contract_context = new WsdlContractConversionContext(sep.Contract, port_type); WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext( contract_context, sep, port, wsb); foreach (IWsdlImportExtension extension in wsdl_extensions) { extension.ImportEndpoint(this, endpoint_context); } }
private void CallExtension(WsdlEndpointConversionContext endpointContext, IWsdlExportExtension extension) { try { extension.ExportEndpoint(this, endpointContext); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.ThrowExtensionException(endpointContext.Endpoint, extension, exception)); } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext) { if (endpointContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); } if (endpointContext.Endpoint.Binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext.Binding"); } if (endpointContext.Endpoint.Binding is CustomBinding) { System.ServiceModel.Channels.Binding binding; BindingElementCollection elements = ((CustomBinding) endpointContext.Endpoint.Binding).Elements; TransportBindingElement element = elements.Find<TransportBindingElement>(); if (element is HttpTransportBindingElement) { if (WSHttpBindingBase.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if (WSDualHttpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if (BasicHttpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } } else if ((element is MsmqTransportBindingElement) && NetMsmqBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if ((element is NamedPipeTransportBindingElement) && NetNamedPipeBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if ((element is PeerTransportBindingElement) && NetPeerTcpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if ((element is TcpTransportBindingElement) && NetTcpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } } }
static void ImportAddress(WsdlEndpointConversionContext context, TransportBindingElement transportBindingElement) { EndpointAddress address = context.Endpoint.Address = WsdlImporter.WSAddressingHelper.ImportAddress(context.WsdlPort); if (address != null) { context.Endpoint.Address = address; // Replace the http BE with https BE only if the uri scheme is https and the transport binding element is a HttpTransportBindingElement but not HttpsTransportBindingElement if (address.Uri.Scheme == Uri.UriSchemeHttps && transportBindingElement is HttpTransportBindingElement && !(transportBindingElement is HttpsTransportBindingElement)) { BindingElementCollection elements = ConvertToCustomBinding(context).Elements; elements.Remove(transportBindingElement); elements.Add(CreateHttpsFromHttp(transportBindingElement as HttpTransportBindingElement)); } } }
internal static SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter) { if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None) { return(null); } SoapOperationBinding soapOperationBinding = GetSoapOperationBinding(endpointContext, operation); OperationBinding operationBinding = endpointContext.GetOperationBinding(operation); EnvelopeVersion soapVersion = GetSoapVersion(endpointContext.WsdlBinding); if (soapOperationBinding != null) { return(soapOperationBinding); } return(CreateSoapOperationBinding(soapVersion, operationBinding)); }
internal static WsdlNS.SoapBinding GetOrCreateSoapBinding(WsdlEndpointConversionContext endpointContext, WsdlExporter exporter) { if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None) { return(null); } WsdlNS.SoapBinding existingSoapBinding = GetSoapBinding(endpointContext); if (existingSoapBinding != null) { return(existingSoapBinding); } EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding); WsdlNS.SoapBinding soapBinding = CreateSoapBinding(version, endpointContext.WsdlBinding); return(soapBinding); }
public void ImportEndpoint (WsdlImporter importer, WsdlEndpointConversionContext context) { var custom = context.Endpoint.Binding as CustomBinding; if (custom == null) return; var soapHttp = GetHttpSoapBinding (context.WsdlBinding); if (soapHttp != null) { ImportBasicHttpBinding (importer, context, custom, soapHttp); return; } var soapTcp = GetTcpSoapBinding (context.WsdlBinding); if (soapTcp != null) { ImportNetTcpBinding (importer, context, custom, soapTcp); return; } }
bool DoImportEndpoint (WsdlEndpointConversionContext context) { WS.SoapAddressBinding address = null; foreach (var extension in context.WsdlPort.Extensions) { var check = extension as WS.SoapAddressBinding; if (check != null) { address = check; break; } } if (address == null) return false; context.Endpoint.Address = new EndpointAddress (address.Location); context.Endpoint.ListenUri = new Uri (address.Location); context.Endpoint.ListenUriMode = ListenUriMode.Explicit; return true; }
internal static WsdlNS.SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter) { if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None) { return(null); } WsdlNS.SoapOperationBinding existingSoapOperationBinding = GetSoapOperationBinding(endpointContext, operation); WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation); EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding); if (existingSoapOperationBinding != null) { return(existingSoapOperationBinding); } WsdlNS.SoapOperationBinding soapOperationBinding = CreateSoapOperationBinding(version, wsdlOperationBinding); return(soapOperationBinding); }
/// <summary> /// Called when importing an endpoint. /// </summary> /// <param name="importer">The importer.</param> /// <param name="context">The import context to modify.</param> public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (context.Endpoint.Binding == null) { throw new ArgumentNullException("context.Endpoint.Binding"); } BindingElementCollection bindingElements = context.Endpoint.Binding.CreateBindingElements(); TransportBindingElement transportBindingElement = bindingElements.Find<TransportBindingElement>(); if (transportBindingElement is UdpTransportBindingElement) { ImportAddress(context); } }
public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "ExportEndpoint"); try { System.Web.Services.Description.ServiceDescription wsdl = exporter.GeneratedWsdlDocuments[0]; XmlSchemaSet schemaSet = exporter.GeneratedXmlSchemas; XmlSchemas imports = new XmlSchemas(); foreach (XmlSchema schema in exporter.GeneratedXmlSchemas.Schemas()) { imports.Add(schema); } foreach (XmlSchema schema in imports) { schema.Includes.Clear(); } wsdl.Types.Schemas.Clear(); wsdl.Types.Schemas.Add(imports); //List<XmlSchema> importsList = new List<XmlSchema>(); // foreach (XmlSchema schema in wsdl.Types.Schemas) // { // AddImportedSchemas(schema, schemaSet, importsList); // } // wsdl.Types.Schemas.Clear(); // foreach (XmlSchema schema in importsList) // { // RemoveXsdImports(schema); // wsdl.Types.Schemas.Add(schema); // } //} } catch (Exception ex) { Log.Exception(PROC, ex); } }
public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } if (context.Endpoint.Binding == null) { throw FxTrace.Exception.ArgumentNull("context.Endpoint.Binding"); } BindingElementCollection bindingElements = context.Endpoint.Binding.CreateBindingElements(); TransportBindingElement transportBindingElement = bindingElements.Find<TransportBindingElement>(); if (transportBindingElement is UdpTransportBindingElement) { ImportEndpointAddress(context); } if (context.Endpoint.Binding is CustomBinding) { Binding newEndpointBinding = null; if (transportBindingElement is UdpTransportBindingElement) { Binding udpBinding; if (UdpBinding.TryCreate(bindingElements, out udpBinding)) { newEndpointBinding = udpBinding; } if (newEndpointBinding != null) { newEndpointBinding.Name = context.Endpoint.Binding.Name; newEndpointBinding.Namespace = context.Endpoint.Binding.Namespace; context.Endpoint.Binding = newEndpointBinding; } } } }
public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { foreach (object extension in context.WsdlPort.Extensions) { SoapAddressBinding addr = (extension as SoapAddressBinding); if (addr != null) { addr.Location = this.location.ToString(); } } EnumerateWsdlsAndSchemas(exporter.GeneratedWsdlDocuments, exporter.GeneratedXmlSchemas); foreach (ServiceDescription description in exporter.GeneratedWsdlDocuments) { FixImportAddresses(exporter.GeneratedWsdlDocuments, description, exporter.GeneratedXmlSchemas); } foreach (XmlSchema schema in exporter.GeneratedXmlSchemas.Schemas()) { FixImportAddresses(exporter.GeneratedXmlSchemas, schema); } }
public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { XmlSchemaSet schemaSet = exporter.GeneratedXmlSchemas; foreach (ServiceDescription wsdl in exporter.GeneratedWsdlDocuments) { List<XmlSchema> importsList = new List<XmlSchema>(); foreach (XmlSchema schema in wsdl.Types.Schemas) { AddImportedSchemas(schema, schemaSet, importsList); } wsdl.Types.Schemas.Clear(); foreach (XmlSchema schema in importsList) { //RemoveXsdImports(schema); wsdl.Types.Schemas.Add(schema); } } }
public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { Console.WriteLine("ImportEndpoint"); if (context == null) { throw new ArgumentNullException("context"); } if (context.Endpoint.Binding == null) { throw new ArgumentNullException("context.Endpoint.Binding"); } BindingElementCollection bindingElements = context.Endpoint.Binding.CreateBindingElements(); TransportBindingElement transportBindingElement = bindingElements.Find<TransportBindingElement>(); if (transportBindingElement is SsbBindingElement) { ImportAddress(context); } if (context.Endpoint.Binding is CustomBinding) { Binding binding; if (transportBindingElement is SsbBindingElement) { //if TryCreate is true, the CustomBinding will be replace by a SampleProfileUdpBinding in the //generated config file for better typed generation. if (SsbBinding.TryCreate(bindingElements, out binding)) { binding.Name = context.Endpoint.Binding.Name; binding.Namespace = context.Endpoint.Binding.Namespace; context.Endpoint.Binding = binding; } } } }
/// <summary> /// Writes custom Web Services Description Language (WSDL) elements into /// the generated WSDL for an endpoint. /// </summary> public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { // We don't support more than one WSDL. if (exporter.GeneratedWsdlDocuments.Count > 1) { Trace.TraceError(Resources.ExInconsistantXmlNamespaces); throw new InvalidOperationException(Resources.ExInconsistantXmlNamespaces); } ServiceDescription wsdl = exporter.GeneratedWsdlDocuments[0]; XmlSchemaSet schemaSet = exporter.GeneratedXmlSchemas; Collection<XmlSchema> importsList = new Collection<XmlSchema>(); for (int i = 0; i < wsdl.Types.Schemas.Count; i++) { XmlSchema schema = wsdl.Types.Schemas[i]; ResolveImportedSchemas(schema, schemaSet, importsList); // If we don't have anything else (e.g. inlined types) // in this schema, we can remove it. if (schema.Includes.Count == 0 && schema.Items.Count == 0) { wsdl.Types.Schemas.RemoveAt(i--); } } // Finally, add each of the real schemas we extracted in the above step. while(importsList.Count != 0) { int l = importsList.Count - 1; wsdl.Types.Schemas.Add(importsList[l]); importsList.RemoveAt(l); } }
private static void EnsureMessageEncoding(WsdlEndpointConversionContext context, MessageEncodingBindingElement encodingBindingElement) { AddressingVersion none; EnvelopeVersion soapVersion = SoapHelper.GetSoapVersion(context.WsdlBinding); if (encodingBindingElement == null) { encodingBindingElement = new TextMessageEncodingBindingElement(); ConvertToCustomBinding(context).Elements.Add(encodingBindingElement); none = AddressingVersion.None; } else if (soapVersion == EnvelopeVersion.None) { none = AddressingVersion.None; } else { none = encodingBindingElement.MessageVersion.Addressing; } MessageVersion messageVersion = MessageVersion.CreateVersion(soapVersion, none); if (!encodingBindingElement.MessageVersion.IsMatch(messageVersion)) { ConvertToCustomBinding(context).Elements.Find<MessageEncodingBindingElement>().MessageVersion = MessageVersion.CreateVersion(soapVersion, none); } }
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { }
internal static SoapHeaderBinding CreateSoapHeaderBinding(WsdlEndpointConversionContext endpointContext, MessageBinding wsdlMessageBinding) { return(CreateSoapHeaderBinding(GetSoapVersion(endpointContext.WsdlBinding), wsdlMessageBinding)); }
EndpointExportMap ExportEndpoint_Internal(ServiceEndpoint endpoint) { var map = ExportedEndpoints.FirstOrDefault(m => m.Endpoint == endpoint); if (map != null) { return(map); } int index = 0; var baseName = String.Concat(endpoint.Binding.Name, "_", endpoint.Contract.Name); var name = baseName; while (ExportedEndpoints.Exists(m => m.Name == name)) { name = String.Concat(baseName, (++index).ToString()); } map = new EndpointExportMap(name, endpoint); ExportedEndpoints.Add(map); var contract = ExportContractInternal(endpoint.Contract); //FIXME: Namespace WSServiceDescription sd = GetServiceDescription("http://tempuri.org/"); if (sd.TargetNamespace != endpoint.Contract.Namespace) { sd.Namespaces.Add("i0", endpoint.Contract.Namespace); //Import Import import = new Import(); import.Namespace = endpoint.Contract.Namespace; sd.Imports.Add(import); } if (endpoint.Binding == null) { throw new ArgumentException(String.Format( "Binding for ServiceEndpoint named '{0}' is null", endpoint.Name)); } var extensions = new List <IWsdlExportExtension> (); var extensionTypes = new Dictionary <Type, IWsdlExportExtension> (); if (contract.Results != null) { foreach (var extension in contract.Results) { var type = extension.GetType(); if (extensionTypes.ContainsKey(type)) { continue; } extensionTypes.Add(type, extension); extensions.Add(extension); } } var bindingElements = endpoint.Binding.CreateBindingElements(); foreach (var element in bindingElements) { var extension = element as IWsdlExportExtension; if (extension == null) { continue; } var type = extension.GetType(); if (extensionTypes.ContainsKey(type)) { continue; } extensionTypes.Add(type, extension); extensions.Add(extension); } //ExportBinding WSBinding ws_binding = new WSBinding(); //<binding name = .. ws_binding.Name = name; //<binding type = .. ws_binding.Type = new QName(endpoint.Contract.Name, endpoint.Contract.Namespace); sd.Bindings.Add(ws_binding); // <operation foreach (OperationDescription sm_op in endpoint.Contract.Operations) { var op_binding = CreateOperationBinding(endpoint, sm_op); ws_binding.Operations.Add(op_binding); } //Add <service Port ws_port = ExportService(sd, ws_binding, endpoint.Address); //Call IWsdlExportExtension.ExportEndpoint WsdlContractConversionContext contract_context = new WsdlContractConversionContext( endpoint.Contract, sd.PortTypes [endpoint.Contract.Name]); WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext( contract_context, endpoint, ws_port, ws_binding); foreach (var extension in extensions) { try { extension.ExportEndpoint(this, endpoint_context); } catch (Exception ex) { var error = AddError( "Failed to export endpoint '{0}': wsdl exporter '{1}' " + "threw an exception: {2}", endpoint.Name, extension.GetType(), ex); throw new MetadataExportException(error, ex); } } try { ExportPolicy(endpoint, ws_binding); } catch (MetadataExportException) { throw; } catch (Exception ex) { var error = AddError( "Failed to export endpoint '{0}': unhandled exception " + "while exporting policy: {1}", endpoint.Name, ex); throw new MetadataExportException(error, ex); } return(map); }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { }
void System.ServiceModel.Description.IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext) { }
public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { }