예제 #1
0
        public IDXVCSService CreateService(string serviceUrl)
        {
            if (isServiceRegistered)
            {
                try {
                    int version = service.GetServiceVersion();
                    return(service);
                }
                catch {
                }
            }
            EndpointAddress myEndpointAddress      = new EndpointAddress(new Uri(serviceUrl), new SpnEndpointIdentity(String.Empty));
            ServiceEndpoint point                  = GZipMessageEncodingBindingElement.CreateEndpoint(myEndpointAddress);
            ChannelFactory <IDXVCSService> factory = new Factory(point);

            factory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
            IDXVCSService   newService = factory.CreateChannel();
            IContextChannel newChannel = (IContextChannel)newService;

            newChannel.OperationTimeout = TimeSpan.MaxValue;
            newChannel.Open();
            service             = newService;
            isServiceRegistered = true;
            service             = new ServiceWrapper(newService);
            return(service);
        }
예제 #2
0
        public IDXVCSService GetService(string serviceUrl)
        {
            EndpointAddress myEndpointAddress      = new EndpointAddress(new Uri(serviceUrl), new SpnEndpointIdentity(String.Empty));
            ServiceEndpoint point                  = GZipMessageEncodingBindingElement.CreateEndpoint(myEndpointAddress, typeof(IDXVCSService));
            ChannelFactory <IDXVCSService> factory = new Factory(point);

            factory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
            IDXVCSService   newService = factory.CreateChannel();
            IContextChannel newChannel = (IContextChannel)newService;

            newChannel.OperationTimeout = TimeSpan.FromSeconds(10);
            newChannel.Open();
            return(new ServiceWrapper(newService));
        }
예제 #3
0
 public static ServiceBase <IDXVCSService> ConnectWCF(string auxPath, string user, string password)
 {
     lock (services) {
         WCFService <IDXVCSService> service;
         string serviceName = string.Format("{0}#$%%$#{1}#@%%@#{2}", auxPath, string.IsNullOrEmpty(user) ? string.Empty : user, string.IsNullOrEmpty(password));
         if (!services.TryGetValue(serviceName, out service))
         {
             EndpointAddress myEndpointAddress      = new EndpointAddress(new Uri(auxPath), new SpnEndpointIdentity(String.Empty));
             ServiceEndpoint point                  = GZipMessageEncodingBindingElement.CreateEndpoint(myEndpointAddress, typeof(IDXVCSService));
             ChannelFactory <IDXVCSService> factory = new Factory <IDXVCSService>(point);
             factory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
             if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(password))
             {
                 factory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(user, password);
             }
             service = new WCFService <IDXVCSService>(factory);
             services.Add(serviceName, service);
         }
         return(service);
     }
 }