Пример #1
0
        private WsdlImporter CreateImporterFromMetadata(MetadataSet metaDocs)
        {
            var    importer = new WsdlImporter(metaDocs);
            object dataContractImporter;
            XsdDataContractImporter xsdDcImporter;

            if (!importer.State.TryGetValue(typeof(XsdDataContractImporter), out dataContractImporter))
            {
                Console.WriteLine("Couldn't find the XsdDataContractImporter! Adding custom importer.");
                xsdDcImporter = new XsdDataContractImporter {
                    Options = new ImportOptions()
                };
                importer.State.Add(typeof(XsdDataContractImporter), xsdDcImporter);
            }
            else
            {
                xsdDcImporter = (XsdDataContractImporter)dataContractImporter;
                if (xsdDcImporter.Options == null)
                {
                    Console.WriteLine("There were no ImportOptions on the importer.");
                    xsdDcImporter.Options = new ImportOptions();
                }
            }
            return(importer);
        }
Пример #2
0
        internal static Binding GetBindingFromMetadata(EndpointDiscoveryMetadata metadata)
        {
            var metadataExtension =
                (from extension in metadata.Extensions
                 where extension.Name == WcfConstants.EndpointMetadata
                 select extension).FirstOrDefault();

            if (metadataExtension == null)
            {
                return(null);
            }

            var endpointMetadata = metadataExtension.Elements().FirstOrDefault();

            if (endpointMetadata == null)
            {
                return(null);
            }

            using (var xmlReader = endpointMetadata.CreateReader())
            {
                var metadataSet = MetadataSet.ReadFrom(xmlReader);
                var importer    = new WsdlImporter(metadataSet);
                var endpoints   = importer.ImportAllEndpoints();
                if (endpoints.Count > 0)
                {
                    return(endpoints[0].Binding);
                }
            }

            return(null);
        }
        public FactoryServiceHelper(Uri url)
        {
            adresse = url;
            Uri mexAddress = new Uri(adresse.ToString() + "?wsdl");
            //for MEX endpoints use a MEX address and a mexMode of .MetadataExchange
            MetadataExchangeClientMode mexMode   = MetadataExchangeClientMode.HttpGet;
            MetadataExchangeClient     mexClient = new MetadataExchangeClient(mexAddress, mexMode);

            mexClient.ResolveMetadataReferences = true;
            serviceMetadata = mexClient.GetMetadata();

            WsdlImporter importer = new WsdlImporter(serviceMetadata);

            System.Collections.ObjectModel.Collection <ContractDescription> contracts = importer.ImportAllContracts();

            BasicHttpBinding Binding = new BasicHttpBinding();
            EndpointAddress  address = new EndpointAddress(adresse.ToString());

            ChannelFactory <IRequestChannel> factory =
                new ChannelFactory <IRequestChannel>(Binding, address);

            serviceChannel  = factory.CreateChannel();
            serviceInfo     = contracts[0];
            targetNamespace = serviceInfo.Namespace;
            serviceName     = serviceInfo.Name;
        }
Пример #4
0
        static void GenerateVBCodeForService(Uri metadataAddress, string outputFile)
        {
            MetadataExchangeClient mexClient = new MetadataExchangeClient(metadataAddress, MetadataExchangeClientMode.HttpGet);

            mexClient.ResolveMetadataReferences = true;
            MetadataSet metaDocs = mexClient.GetMetadata();

            WsdlImporter             importer  = new WsdlImporter(metaDocs);
            ServiceContractGenerator generator = new ServiceContractGenerator();

            System.Collections.ObjectModel.Collection <ContractDescription> contracts = importer.ImportAllContracts();
            foreach (ContractDescription contract in contracts)
            {
                generator.GenerateServiceContractType(contract);
            }
            if (generator.Errors.Count != 0)
            {
                throw new ApplicationException("There were errors during code compilation.");
            }

            // Write the code dom.
            System.CodeDom.Compiler.CodeGeneratorOptions options = new System.CodeDom.Compiler.CodeGeneratorOptions();
            options.BracingStyle = "C";
            System.CodeDom.Compiler.CodeDomProvider    codeDomProvider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("VB");
            System.CodeDom.Compiler.IndentedTextWriter textWriter      = new System.CodeDom.Compiler.IndentedTextWriter(new System.IO.StreamWriter(outputFile));
            codeDomProvider.GenerateCodeFromCompileUnit(generator.TargetCompileUnit, textWriter, options);
            textWriter.Close();
        }
Пример #5
0
        /// <summary>
        /// Applies the WSDL importers configuration.
        /// </summary>
        /// <param name="importer">The importer.</param>
        public void ApplyWsdlImportersConfiguration(WsdlImporter importer)
        {
            if (importer == null)
            {
                return;
            }

            if (_element == null)
            {
                lock (SyncLock)
                {
                    if (_element == null)
                    {
                        Deserialize();
                    }
                }
            }

            foreach (WsdlImporterElement item in _element.WsdlImporters)
            {
                var type      = Activation.WcfServiceHostFactory.GetType(item.Type, true);
                var extension = Activator.CreateInstance(type) as IWsdlImportExtension;
                importer.WsdlImportExtensions.Add(extension);
            }
        }
Пример #6
0
        void AddStateForDataContractSerializerImport(WsdlImporter importer)
        {
            XsdDataContractImporter xsdDataContractImporter =
                new XsdDataContractImporter(this.codeCompileUnit);

            xsdDataContractImporter.Options = new ImportOptions();
            xsdDataContractImporter.Options.ImportXmlType =
                (this.options.FormatMode ==
                 DynamicProxyFactoryOptions.FormatModeOptions.DataContractSerializer);

            xsdDataContractImporter.Options.CodeProvider = this.codeDomProvider;
            importer.State.Add(typeof(XsdDataContractImporter),
                               xsdDataContractImporter);

            foreach (IWsdlImportExtension importExtension in importer.WsdlImportExtensions)
            {
                DataContractSerializerMessageContractImporter dcConverter =
                    importExtension as DataContractSerializerMessageContractImporter;

                if (dcConverter != null)
                {
                    if (this.options.FormatMode ==
                        DynamicProxyFactoryOptions.FormatModeOptions.XmlSerializer)
                    {
                        dcConverter.Enabled = false;
                    }
                    else
                    {
                        dcConverter.Enabled = true;
                    }
                }
            }
        }
Пример #7
0
        private static void GenerateCodeDomTree(WsdlImporter wsdlImporter, ServiceContractGenerator contractGenerator)
        {
            Collection <ContractDescription> contracts = wsdlImporter.ImportAllContracts();
            Collection <Binding>             bindings  = wsdlImporter.ImportAllBindings();
            ServiceEndpointCollection        endpoints = wsdlImporter.ImportAllEndpoints();

            if (wsdlImporter.Errors.Any(e => !e.IsWarning))
            {
                throw new CodeGenerationException(wsdlImporter.Errors);
            }

            foreach (ContractDescription contract in contracts)
            {
                //TODO:Alex:Make the naming scheme customisable.
                contract.Name = "I" + contract.Name.Replace("Interface", string.Empty);
                contractGenerator.GenerateServiceContractType(contract);
            }

            foreach (Binding binding in bindings)
            {
                string bindingSectionName, configurationName;
                contractGenerator.GenerateBinding(binding, out bindingSectionName, out configurationName);
            }

            foreach (ServiceEndpoint endpoint in endpoints)
            {
                ChannelEndpointElement channelElement;
                contractGenerator.GenerateServiceEndpoint(endpoint, out channelElement);
            }
        }
Пример #8
0
        static ServiceEndpointCollection QueryMexEndpoint(string mexAddress, Binding binding, string issuer, string secret)
        {
            Binding extendedBinding = null;

            if (binding is NetTcpRelayBinding)
            {
                NetTcpRelayBinding actualBinding = binding as NetTcpRelayBinding;
                actualBinding.MaxReceivedMessageSize *= MessageSizeMultiplier;
                extendedBinding = actualBinding;
            }
            if (binding is WS2007HttpRelayBinding)
            {
                WS2007HttpRelayBinding actualBinding = binding as WS2007HttpRelayBinding;
                actualBinding.MaxReceivedMessageSize *= MessageSizeMultiplier;
                extendedBinding = actualBinding;
            }

            MetadataExchangeClient mexClient = new MetadataExchangeClient(extendedBinding);

            mexClient.SetServiceBusCredentials(issuer, secret);
            MetadataSet      metadata = mexClient.GetMetadata(new EndpointAddress(mexAddress));
            MetadataImporter importer = new WsdlImporter(metadata);

            return(importer.ImportAllEndpoints());
        }
Пример #9
0
        public void CtorNullTest5()
        {
            WsdlImporter wi = new WsdlImporter(new MetadataSet());

            CheckDefaultWsdlImportExtensions(wi.WsdlImportExtensions);
            CheckDefaultPolicyImportExtensions(wi.PolicyImportExtensions);
        }
Пример #10
0
        void ConfigureImporter(WsdlImporter importer)
        {
            var xsdImporter = new XsdDataContractImporter();
            var options     = new ImportOptions();

            var listMapping = refGroup.ClientOptions.CollectionMappings.FirstOrDefault(
                m => m.Category == "List");

            if (listMapping != null)
            {
                var listType = Dialogs.WCFConfigWidget.GetType(listMapping.TypeName);
                if (listType != null)
                {
                    options.ReferencedCollectionTypes.Add(listType);
                }
            }

            var dictMapping = refGroup.ClientOptions.CollectionMappings.FirstOrDefault(
                m => m.Category == "Dictionary");

            if (dictMapping != null)
            {
                var dictType = Dialogs.WCFConfigWidget.GetType(dictMapping.TypeName);
                if (dictType != null)
                {
                    options.ReferencedCollectionTypes.Add(dictType);
                }
            }

            xsdImporter.Options = options;
            importer.State.Add(typeof(XsdDataContractImporter), xsdImporter);
        }
        void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

#pragma warning disable 56506 // elliotw, these properties cannot be null in this context
            if (context.Endpoint.Binding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding");
            }

#pragma warning disable 56506 // brianmcn, CustomBinding.Elements never be null
            TransportBindingElement transportBindingElement = GetBindingElements(context).Find <TransportBindingElement>();

            bool transportHandledExternaly = (transportBindingElement != null) && !StateHelper.IsRegisteredTransportBindingElement(importer, context);
            if (transportHandledExternaly)
            {
                return;
            }

#pragma warning disable 56506 // elliotw, 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);
            }
        }
Пример #12
0
        public static CodeCompileUnit Import(MetadataSet metadata, ImportOptions options)
        {
            var importer    = new WsdlImporter(metadata);
            var xsdImporter = new XsdDataContractImporter();

            xsdImporter.Options = options;
            importer.State.Add(typeof(XsdDataContractImporter), xsdImporter);

            var contracts = importer.ImportAllContracts();

            CodeCompileUnit ccu       = new CodeCompileUnit();
            var             generator = new ServiceContractGenerator(ccu);

            if (contracts.Count != 1)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Metadata import failed: found {0} contracts.", contracts.Count));
            }

            var contract = contracts.First();

            generator.GenerateServiceContractType(contract);

            return(ccu);
        }
Пример #13
0
        public void WsdlImported(WsdlImporter importer, Collection <ServiceEndpoint> endpoints, Collection <Binding> bindings, Collection <ContractDescription> contracts)
        {
            RunFixups(MetadataFixup.GetPostFixups(importer, endpoints, bindings, contracts), _options);

            bool hasContractOperations = false;

            foreach (var contract in contracts)
            {
                if (contract.Operations.Count > 0)
                {
                    hasContractOperations = true;
                    break;
                }
            }

            if (endpoints.Count == 0 || bindings.Count == 0 || contracts.Count == 0 || !hasContractOperations)
            {
                MetadataConversionError error = new MetadataConversionError(SR.ErrNoCompatibleEndpoints, isWarning: true);
                if (!importer.Errors.Contains(error))
                {
                    importer.Errors.Add(error);
                }
            }

            UpdateExitStatus(importer.Errors);
            _endpoints = endpoints;
        }
Пример #14
0
// </Snippet0>

        static void CallFromMain(string[] args)
        {
            //<snippet10>
            // make endpoint address
            EndpointAddress mexAddress = new EndpointAddress("http://localhost:8080/ServiceMetadata/mex");

            // Download all metadata. The policy importer runs automatically.p
            ServiceEndpointCollection endpoints
                = MetadataResolver.Resolve(
                      typeof(IStatefulService),
                      new EndpointAddress("http://localhost:8080/StatefulService/mex")
                      );
            //</snippet10>

            MetadataExchangeClient mexClient =
                new MetadataExchangeClient(mexAddress);

            mexClient.ResolveMetadataReferences = true;

            MetadataSet metaDocs = mexClient.GetMetadata();

            WsdlImporter importer = new WsdlImporter(metaDocs);
            // This is not neccesary for this snippet.
            // PolicyConversionContext myPolicyConversionContext = new PolicyConversionContext ();
            //ImportPolicy(importer, myPolicyConversionContext);
        }
Пример #15
0
        static void ImportAllEndpoints()
        {
            EndpointAddress        mexAddress = new EndpointAddress(uri + "/mex");
            MetadataExchangeClient mexClient  = new MetadataExchangeClient(mexAddress);

            // Retrieve the metadata for all endpoints using metadata exchange protocol (mex).
            MetadataSet metadataSet = mexClient.GetMetadata();

            //Convert the metadata into endpoints
            WsdlImporter importer = new WsdlImporter(metadataSet);

            #region endpoints
            ServiceEndpointCollection endpoints = importer.ImportAllEndpoints();

            ContractDescription contract = ContractDescription.GetContract(typeof(ICalculator));
            // Communicate with each endpoint that supports the ICalculator contract.
            foreach (ServiceEndpoint ep in endpoints)
            {
                if (ep.Contract.Namespace.Equals(contract.Namespace) && ep.Contract.Name.Equals(contract.Name))
                {
                    // Create a client using the endpoint address and binding.
                    var client = new ChannelFactory <CalculatorClientChannel>(ep.Binding, new EndpointAddress(ep.Address.Uri)).CreateChannel();

                    // call operations
                    Console.WriteLine(client.Add(2, 3));

                    //Closing the client gracefully closes the connection and cleans up resources
                    client.Close();
                }
            }
            #endregion
        }
Пример #16
0
        private void AddStateForDataContractSerializerImport(WsdlImporter importer)
        {
            var importOptions = new ImportOptions();

            importOptions.GenerateSerializable = true;
            //importOptions.GenerateInternal = true;
            importOptions.EnableDataBinding = true;
            importOptions.ImportXmlType     = (Options.FormatMode == DynamicProxyLoaderOptions.FormatModeOptions.DataContractSerializer);
            importOptions.CodeProvider      = codeDomProvider;

            foreach (var pair in Options.Namespaces)
            {
                importOptions.Namespaces.Add(pair.Key, pair.Value);
            }

            var xsdDataContractImporter = new XsdDataContractImporter(codeCompileUnit);

            xsdDataContractImporter.Options = importOptions;

            importer.State.Add(typeof(XsdDataContractImporter), xsdDataContractImporter);

            foreach (var importExtension in importer.WsdlImportExtensions)
            {
                var dcConverter = importExtension as DataContractSerializerMessageContractImporter;
                if (dcConverter != null)
                {
                    dcConverter.Enabled = (Options.FormatMode != DynamicProxyLoaderOptions.FormatModeOptions.XmlSerializer);
                }
            }
        }
Пример #17
0
        private void WSDLImport(string metadataAddress)
        {
            //<snippet9>
            MetadataExchangeClient mexClient = new MetadataExchangeClient(metadataAddress);

            mexClient.ResolveMetadataReferences = true;
            MetadataSet             metaDocs = mexClient.GetMetadata();
            WsdlImporter            importer = new WsdlImporter(metaDocs);
            object                  dataContractImporter;
            XsdDataContractImporter xsdInventoryImporter;

            if (!importer.State.TryGetValue(typeof(XsdDataContractImporter),
                                            out dataContractImporter))
            {
                xsdInventoryImporter = new XsdDataContractImporter();
            }

            xsdInventoryImporter = (XsdDataContractImporter)dataContractImporter;
            if (xsdInventoryImporter.Options == null)
            {
                xsdInventoryImporter.Options = new ImportOptions();
            }
            xsdInventoryImporter.Options.DataContractSurrogate = new InventorySurrogated();
            importer.State.Add(typeof(XsdDataContractImporter), xsdInventoryImporter);

            Collection <ContractDescription> contracts = importer.ImportAllContracts();
            //</snippet9>
        }
        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");
            }
            TransportBindingElement transportBindingElement = GetBindingElements(context).Find <TransportBindingElement>();

            if ((transportBindingElement == null) || StateHelper.IsRegisteredTransportBindingElement(importer, context))
            {
                SoapBinding soapBinding = (SoapBinding)context.WsdlBinding.Extensions.Find(typeof(SoapBinding));
                if ((soapBinding != null) && (transportBindingElement == null))
                {
                    CreateLegacyTransportBindingElement(importer, soapBinding, context);
                }
                if (context.WsdlPort != null)
                {
                    ImportAddress(context, transportBindingElement);
                }
            }
        }
Пример #19
0
        void NoExtensionsSetup()
        {
            XmlReaderSettings xs = new XmlReaderSettings();

            xs.IgnoreWhitespace = true;
            xtr = XmlTextReader.Create("Test/System.ServiceModel.Description/dump.xml", xs);

            xtr.Read();

            //FIXME: skipping Headers
            while (xtr.LocalName != "Body")
            {
                if (!xtr.Read())
                {
                    return;
                }
            }

            //Move to <Metadata ..
            xtr.Read();
            ms = MetadataSet.ReadFrom(xtr);

            //MyWsdlImportExtension mw = new MyWsdlImportExtension ();
            List <IWsdlImportExtension> list = new List <IWsdlImportExtension> ();

            //list.Add (mw);
            list.Add(new DataContractSerializerMessageContractImporter());

            /*list.Add (new MessageEncodingBindingElementImporter ());
             * list.Add (new TransportBindingElementImporter ());
             * list.Add (new StandardBindingImporter ());*/

            wi = new WsdlImporter(ms, null, list);
        }
        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);
                }
            }
        }
Пример #21
0
        private void AddStateForFaultSerializerImport(WsdlImporter importer)
        {
            var faultImportOptions = new FaultImportOptions();

            faultImportOptions.UseMessageFormat = true;

            importer.State.Add(typeof(FaultImportOptions), faultImportOptions);
        }
Пример #22
0
        public void CtorNullTest4()
        {
            WsdlImporter wi = new WsdlImporter(new MetadataSet(), null, null);

            /* FIXME: Not all importers are implemented yet */
            CheckDefaultPolicyImportExtensions(wi.PolicyImportExtensions);
            CheckDefaultWsdlImportExtensions(wi.WsdlImportExtensions);
        }
Пример #23
0
        private void AddStateForDataContractSerializerImport(ContractGenerationOptions options,
                                                             WsdlImporter wsdlImporter, CodeCompileUnit codeCompileUnit)
        {
            XsdDataContractImporter xsdImporter = new XsdDataContractImporter(codeCompileUnit);

            xsdImporter.Options = CreateDataContractImportOptions(options);
            wsdlImporter.State.Add(typeof(XsdDataContractImporter), xsdImporter);
        }
 public void ImportContract(WsdlImporter importer, WsdlContractConversionContext context)
 {
     foreach (Operation operation in context.WsdlPortType.Operations)
     {
         var operationDescription = context.GetOperationDescription(operation);
         operationDescription.OperationBehaviors.Add(this);
     }
 }
Пример #25
0
        /// <summary>
        /// Gets a new <see cref="WsdlImporter"/> instance.
        /// </summary>
        /// <param name="codeGeneratorContext">The code generator context.</param>
        /// <returns>
        /// A new <see cref="WsdlImporter"/> instance.
        /// </returns>
        public WsdlImporter GetWsdlImporter(ICodeGeneratorContext codeGeneratorContext)
        {
            WsdlImporter wsdlImporter = new WsdlImporter(codeGeneratorContext.MetadataSet);

            RemoveUnneededSerializers(wsdlImporter, codeGeneratorContext);
            ConfigureSerializers(wsdlImporter, codeGeneratorContext);

            return(wsdlImporter);
        }
Пример #26
0
 public static IFixup[] GetPostFixups(WsdlImporter importer, Collection <ServiceEndpoint> endpoints, Collection <Binding> bindings, Collection <ContractDescription> contracts)
 {
     return(new IFixup[]
     {
         new EndpointSelector(importer, endpoints, bindings, contracts),
         new NoSoapEncodingFixup(importer, endpoints, bindings, contracts),
         new NoMessageHeaderFixup(importer, endpoints, bindings, contracts)
     });
 }
Пример #27
0
        public static void GetMessagesInfo(MetadataSet metadataSet)
        {
            var wsdlimp   = new WsdlImporter(metadataSet);
            var contracts = wsdlimp.ImportAllContracts();
            var operation = contracts[0].Operations[0];

            var message = operation.Messages.FirstOrDefault(x => x.Direction == MessageDirection.Input);
            var result  = message.Body.Parts.ToArray();
        }
Пример #28
0
        internal ImportModule(CommandProcessorOptions options, ServiceDescriptor serviceDescriptor, WsdlImporter importer)
        {
            _codeCompileUnit  = new CodeCompileUnit();
            _options          = options;
            _codegenExtension = new WcfCodeGenerationExtension(options);

            _wsdlImporter      = importer;
            _contractGenerator = InitializationHelper.CreateServiceContractGenerator(options, _codeCompileUnit);
        }
Пример #29
0
        /// <summary>
        /// Queries the mex endpoint.
        /// </summary>
        /// <param name="mexAddress">The mex address.</param>
        /// <param name="bindingElement">The binding element.</param>
        /// <returns>ServiceEndpointCollection.</returns>
        static ServiceEndpointCollection QueryMexEndpoint(string mexAddress, BindingElement bindingElement)
        {
            var binding               = new CustomBinding(bindingElement);
            var mexClient             = new MetadataExchangeClient(binding);
            var metadata              = mexClient.GetMetadata(new EndpointAddress(mexAddress));
            MetadataImporter importer = new WsdlImporter(metadata);

            return(importer.ImportAllEndpoints());
        }
Пример #30
0
        /// <summary>
        /// Queries the mex contracts.
        /// </summary>
        /// <param name="mexAddress">The mex address.</param>
        /// <param name="bindingElement">The binding element.</param>
        /// <returns>IEnumerable{ContractDescription}.</returns>
        static IEnumerable <ContractDescription> QueryMexContracts(string mexAddress, BindingElement bindingElement)
        {
            var binding               = new CustomBinding(bindingElement);
            var mexClient             = new MetadataExchangeClient(binding);
            var metadata              = mexClient.GetMetadata(new EndpointAddress(mexAddress));
            MetadataImporter importer = new WsdlImporter(metadata);

            return(importer.ImportAllContracts());
        }