public RemoteTagExample(String myUri)
        {
            var Binding = new BasicHttpBinding();
            Binding.Name = "sonesBasic";
            var Uri = new EndpointAddress(myUri);

            _GraphDS_Service = ChannelFactory<GraphDSService>.CreateChannel(Binding, Uri);
            _VertexInstanceService = ChannelFactory<VertexInstanceService>.CreateChannel(Binding, Uri);
            _VertexTypeService = ChannelFactory<VertexTypeService>.CreateChannel(Binding, Uri);
            _EdgeInstanceService = ChannelFactory<EdgeInstanceService>.CreateChannel(Binding, Uri);
            _EdgeTypeService = ChannelFactory<EdgeTypeService>.CreateChannel(Binding, Uri);
        }
Ejemplo n.º 2
0
        public GraphDS_RemoteClient(Uri myServiceAddress, bool myIsSecure = false, bool myUseStreaming = false)
        {
            #if __MonoCS__
            UseStreaming = false;
            #else
            UseStreaming = myUseStreaming;
            #endif

            BasicHttpBinding BasicBinding = new BasicHttpBinding();
            BasicBinding.Name                   = "sonesBasic";
            BasicBinding.MessageEncoding        = WSMessageEncoding.Text;
            BasicBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            BasicBinding.MaxBufferSize          = 268435456;
            BasicBinding.MaxReceivedMessageSize = 268435456;
            BasicBinding.SendTimeout            = new TimeSpan(1, 0, 0);
            BasicBinding.ReceiveTimeout         = new TimeSpan(1, 0, 0);
            XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
            readerQuotas.MaxDepth = 2147483647;
            readerQuotas.MaxStringContentLength = 2147483647;
            readerQuotas.MaxBytesPerRead        = 2147483647;
            readerQuotas.MaxNameTableCharCount  = 2147483647;
            readerQuotas.MaxStringContentLength = int.MaxValue;
            readerQuotas.MaxArrayLength         = 2147483647;
            BasicBinding.ReaderQuotas           = readerQuotas;

            BasicHttpBinding StreamedBinding = new BasicHttpBinding();
            StreamedBinding.Name                   = "sonesStreamed";
            StreamedBinding.MessageEncoding        = WSMessageEncoding.Text;
            StreamedBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            StreamedBinding.MaxReceivedMessageSize = 2147483647;
            StreamedBinding.MaxBufferSize          = (UseStreaming == true) ? 4096 : 2147483647;
            StreamedBinding.SendTimeout            = new TimeSpan(1, 0, 0, 0);
            if (UseStreaming == true)
            {
                StreamedBinding.TransferMode = TransferMode.Streamed;
            }

            if (myIsSecure == true)
            {
                BasicBinding.Security.Mode    = BasicHttpSecurityMode.Transport;
                StreamedBinding.Security.Mode = BasicHttpSecurityMode.Transport;
            }

            try
            {
                //request to test connection
                var Request  = HttpWebRequest.Create(myServiceAddress.ToString());
                var Response = Request.GetResponse();
            }
            catch (Exception ex)
            {
                throw new Exception("The GraphDB remote service is unreachable! Maybe the service was not started.", ex);
            }

            try
            {
                ChannelFactory <GraphDSService> factory = new ChannelFactory <GraphDSService>(BasicBinding, new EndpointAddress(myServiceAddress));
                foreach (var op in factory.Endpoint.Contract.Operations)
                {
                    DataContractSerializerOperationBehavior dataContractBehavior = op.Behaviors.Find <DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
                    if (dataContractBehavior != null)
                    {
                        dataContractBehavior.MaxItemsInObjectGraph = 2147483647;
                    }
                }
                _GraphDSService = factory.CreateChannel();

                _VertexTypeService = ChannelFactory <VertexTypeService> .CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));

                _VertexInstanceService = ChannelFactory <VertexInstanceService> .CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));

                _EdgeTypeService = ChannelFactory <EdgeTypeService> .CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));

                _EdgeInstanceService = ChannelFactory <EdgeInstanceService> .CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));

                _StreamedService = ChannelFactory <StreamedService> .CreateChannel(StreamedBinding, new EndpointAddress(myServiceAddress + "/streamed"));
            }
            catch (Exception ex)
            {
                throw new Exception("The GraphDB is reachably but there occured an error, creating the native services!", ex);
            }
        }