/// <summary>
        /// Gets the service description for the contract interface type
        /// through the MEX exposed endpoint.
        /// </summary>
        /// <param name="contractType">The interface type contract of the service.</param>
        /// <param name="serviceEndpointAddress">The endpoint address of the service MEX.</param>
        /// <param name="mexMode">The metadata exchange client mode.</param>
        /// <returns>The service endpoint description.</returns>
        public static ServiceDescription GetServiceDescription(Type contractType,
                                                               Uri serviceEndpointAddress, MetadataExchangeClientMode mexMode)
        {
            ServiceEndpointCollection svcEndpoints   = GetServiceEndpoints(contractType, serviceEndpointAddress, mexMode);
            ServiceDescription        svcDescription = new ServiceDescription(svcEndpoints.ToArray());

            return(svcDescription);
        }
        /// <summary>
        /// Gets the service description for the contract interface type
        /// through the MEX exposed endpoint.
        /// </summary>
        /// <param name="contractType">The interface type contract of the service.</param>
        /// <param name="serviceEndpointAddress">The endpoint address of the service MEX.</param>
        /// <returns>The service endpoint description.</returns>
        public static ServiceDescription GetServiceDescription(Type contractType,
                                                               string serviceEndpointAddress)
        {
            ServiceEndpointCollection svcEndpoints   = GetServiceEndpoints(contractType, serviceEndpointAddress);
            ServiceDescription        svcDescription = new ServiceDescription(svcEndpoints.ToArray());

            return(svcDescription);
        }
Exemple #3
0
        /// <summary>
        /// Gets the endpoints.
        /// </summary>
        /// <param name="mexAddress">The mex address.</param>
        /// <returns>ServiceEndpoint[][].</returns>
        public static ServiceEndpoint[] GetEndpoints(string mexAddress)
        {
            if (String.IsNullOrEmpty(mexAddress))
            {
                Debug.Assert(false, "Empty address");
                return(null);
            }
            var address = new Uri(mexAddress);
            ServiceEndpointCollection endpoints = null;

            if (address.Scheme == Uri.UriSchemeHttp)
            {
                var be = new HttpTransportBindingElement {
                    MaxReceivedMessageSize = BindingHelper.BindingConst.MaxReceivedMessageSize
                };
                endpoints = GetEndpointsViaHttpMex(mexAddress, be);
            }
            else if (address.Scheme == Uri.UriSchemeHttps)
            {
                var be = new HttpsTransportBindingElement {
                    MaxReceivedMessageSize = BindingHelper.BindingConst.MaxReceivedMessageSize
                };
                endpoints = GetEndpointsViaHttpMex(mexAddress, be);
            }
            else if (address.Scheme == Uri.UriSchemeNetTcp)
            {
                var be = new TcpTransportBindingElement {
                    MaxReceivedMessageSize = BindingHelper.BindingConst.MaxReceivedMessageSize
                };
                endpoints = QueryMexEndpoint(mexAddress, be);
            }
            else if (address.Scheme == Uri.UriSchemeNetPipe)
            {
                var be = new NamedPipeTransportBindingElement {
                    MaxReceivedMessageSize = BindingHelper.BindingConst.MaxReceivedMessageSize
                };
                endpoints = QueryMexEndpoint(mexAddress, be);
            }
            return(endpoints.ToArray());
        }
        public static ServiceEndpoint[] GetEndpoints(string mexAddress, string issuer, string secret)
        {
            if (string.IsNullOrWhiteSpace(mexAddress))
            {
                throw new ArgumentException("mexAddress");
            }

            Uri address = new Uri(mexAddress);

            ServiceEndpointCollection endpoints = null;

            Binding binding;

            if (address.Scheme == "sb")
            {
                binding = new NetTcpRelayBinding();
            }
            else
            {
                Debug.Assert(address.Scheme == "http" || address.Scheme == "https");
                binding = new WS2007HttpRelayBinding();
            }

            try
            {
                endpoints = QueryMexEndpoint(mexAddress, binding, issuer, secret);
            }
            catch
            {}
            if (endpoints != null)
            {
                return(endpoints.ToArray());
            }
            else
            {
                return(new ServiceEndpoint[] {});
            }
        }
 void ProcessMetaData(ServiceNode existingNode, string mexAddress, ServiceEndpointCollection endpoints)
 {
     ProcessMetaData(existingNode, mexAddress, endpoints.ToArray());
 }
        public static ServiceEndpoint[] GetEndpoints(string mexAddress)
        {
            if (String.IsNullOrEmpty(mexAddress))
            {
                Debug.Assert(false, "Empty address");
                return(null);
            }
            Uri address = new Uri(mexAddress);
            ServiceEndpointCollection endpoints = null;

            if (address.Scheme == "http")
            {
                HttpTransportBindingElement httpBindingElement = new HttpTransportBindingElement();
                httpBindingElement.MaxReceivedMessageSize *= MessageSizeMultiplier;

                //Try the HTTP MEX Endpoint
                try
                {
                    endpoints = QueryMexEndpoint(mexAddress, httpBindingElement);
                }
                catch
                { }

                //Try over HTTP-GET
                if (endpoints == null)
                {
                    string httpGetAddress = mexAddress;
                    if (mexAddress.EndsWith("?wsdl") == false)
                    {
                        httpGetAddress += "?wsdl";
                    }
                    CustomBinding          binding   = new CustomBinding(httpBindingElement);
                    MetadataExchangeClient mexClient = new MetadataExchangeClient(binding);
                    MetadataSet            metadata  = mexClient.GetMetadata(new Uri(httpGetAddress), MetadataExchangeClientMode.HttpGet);
                    MetadataImporter       importer  = new WsdlImporter(metadata);
                    endpoints = importer.ImportAllEndpoints();
                }
            }
            if (address.Scheme == "https")
            {
                HttpsTransportBindingElement httpsBindingElement = new HttpsTransportBindingElement();
                httpsBindingElement.MaxReceivedMessageSize *= MessageSizeMultiplier;

                //Try the HTTPS MEX Endpoint
                try
                {
                    endpoints = QueryMexEndpoint(mexAddress, httpsBindingElement);
                }
                catch
                { }

                //Try over HTTPS-GET
                if (endpoints == null)
                {
                    string httpsGetAddress = mexAddress;
                    if (mexAddress.EndsWith("?wsdl") == false)
                    {
                        httpsGetAddress += "?wsdl";
                    }
                    CustomBinding          binding   = new CustomBinding(httpsBindingElement);
                    MetadataExchangeClient mexClient = new MetadataExchangeClient(binding);
                    MetadataSet            metadata  = mexClient.GetMetadata(new Uri(httpsGetAddress), MetadataExchangeClientMode.HttpGet);
                    MetadataImporter       importer  = new WsdlImporter(metadata);
                    endpoints = importer.ImportAllEndpoints();
                }
            }
            if (address.Scheme == "net.tcp")
            {
                TcpTransportBindingElement tcpBindingElement = new TcpTransportBindingElement();
                tcpBindingElement.MaxReceivedMessageSize *= MessageSizeMultiplier;
                endpoints = QueryMexEndpoint(mexAddress, tcpBindingElement);
            }
            if (address.Scheme == "net.pipe")
            {
                NamedPipeTransportBindingElement ipcBindingElement = new NamedPipeTransportBindingElement();
                ipcBindingElement.MaxReceivedMessageSize *= MessageSizeMultiplier;
                endpoints = QueryMexEndpoint(mexAddress, ipcBindingElement);
            }
            return(endpoints.ToArray());
        }
Exemple #7
0
 void ProcessMetaData(ServiceNode existingNode,string mexAddress,ServiceEndpointCollection endpoints)
 {
    ProcessMetaData(existingNode,mexAddress,endpoints.ToArray());
 }
Exemple #8
0
        public static ServiceEndpoint[] GetEndpoints(string mexAddress)
        {
            if (string.IsNullOrWhiteSpace(mexAddress))
            {
                throw new ArgumentException("mexAddress");
            }

            Uri address = new Uri(mexAddress);
            ServiceEndpointCollection endpoints      = null;
            BindingElement            bindingElement = null;

            //Try over HTTP-GET first
            if (address.Scheme == Uri.UriSchemeHttp || address.Scheme == Uri.UriSchemeHttps)
            {
                string getAddress = mexAddress;
                if (mexAddress.EndsWith("?wsdl") == false)
                {
                    getAddress += "?wsdl";
                }
                if (address.Scheme == Uri.UriSchemeHttp)
                {
                    HttpTransportBindingElement httpBindingElement = new HttpTransportBindingElement();
                    httpBindingElement.MaxReceivedMessageSize *= MessageSizeMultiplier;
                    bindingElement = httpBindingElement;
                }
                else
                {
                    HttpsTransportBindingElement httpsBindingElement = new HttpsTransportBindingElement();
                    httpsBindingElement.MaxReceivedMessageSize *= MessageSizeMultiplier;
                    bindingElement = httpsBindingElement;
                }
                CustomBinding binding = new CustomBinding(bindingElement);

                MetadataExchangeClient mexClient = new MetadataExchangeClient(binding);
                MetadataSet            metadata  = mexClient.GetMetadata(new Uri(getAddress), MetadataExchangeClientMode.HttpGet);
                MetadataImporter       importer  = new WsdlImporter(metadata);
                endpoints = importer.ImportAllEndpoints();
                return(endpoints.ToArray());
            }

            //Try MEX endpoint:

            if (address.Scheme == Uri.UriSchemeHttp)
            {
                bindingElement = new HttpTransportBindingElement();
            }
            if (address.Scheme == Uri.UriSchemeHttps)
            {
                bindingElement = new HttpsTransportBindingElement();
            }
            if (address.Scheme == Uri.UriSchemeNetTcp)
            {
                bindingElement = new TcpTransportBindingElement();
            }
            if (address.Scheme == Uri.UriSchemeNetPipe)
            {
                bindingElement = new NamedPipeTransportBindingElement();
            }

            endpoints = QueryMexEndpoint(mexAddress, bindingElement);
            return(endpoints.ToArray());
        }