Exemplo n.º 1
0
 public SOAPManager(
     ref ServiceHost host,
     SOAPServerType soap_server,
     Uri ServiceURL,
     String NameSpace,
     ServiceBindingType bindType,
     MessageCredentialType MessageCredentialType,
     string cerPath,
     string cerPassword,
     object service,
     deleErrReporter errReporter)
 {
     this.errReporter = errReporter;
     switch (soap_server)
     {
         case SOAPServerType.winform:
             SOAPFactory = new soap_WinFormFactory(ref host,ServiceURL, NameSpace, service, bindType, MessageCredentialType, cerPath,cerPassword,new deleErrReporter(ThrowErr));
             break;
         case SOAPServerType.WAS:
             break;
         case SOAPServerType.iis:
             break;
         default:
             break;
     }
 }
Exemplo n.º 2
0
        public SOAPManager
        (
            ref ServiceHost host,
            SOAPServerType soap_server,
            Uri ServiceURL,
            String NameSpace,
            ServiceBindingType bindType,
            MessageCredentialType MessageCredentialType,
            string cerPath,
            string cerPassword,
            object service,
            deleErrReporter errReporter)
        {
            this.errReporter = errReporter;
            switch (soap_server)
            {
            case SOAPServerType.winform:
                SOAPFactory = new soap_WinFormFactory(ref host, ServiceURL, NameSpace, service, bindType, MessageCredentialType, cerPath, cerPassword, new deleErrReporter(ThrowErr));
                break;

            case SOAPServerType.WAS:
                break;

            case SOAPServerType.iis:
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        public SOAPManager
        (
            ref ServiceHost host,
            SOAPServerType soap_server,
            Uri ServiceURL,
            String NameSpace,
            ServiceBindingType bindType,
            Type serviceType,
            Type InterfaceType,
            deleErrReporter errReporter)
        {
            this.errReporter = errReporter;
            switch (soap_server)
            {
            case SOAPServerType.winform:
                SOAPFactory = new soap_WinFormFactory(ref host, ServiceURL, NameSpace, serviceType, InterfaceType, bindType, new deleErrReporter(ThrowErr));
                break;

            case SOAPServerType.WAS:
                break;

            case SOAPServerType.iis:
                break;

            default:
                break;
            }
        }
Exemplo n.º 4
0
 public soap_WinFormFactory
 (
     ref ServiceHost server,
     Uri server_url,
     string NameSpace,
     Type serviceType,
     Type ServiceInterfaceType,
     ServiceBindingType bindType,
     MessageCredentialType MessageCredentialType,
     string certificatePath,
     string certificatePassword,
     deleErrReporter errReporter
 )
 {
     this.server = server;
     // 인증서 설정
     SetCertificate(certificatePath, certificatePassword);
     this.bindType    = bindType;
     this.service     = null;
     this.serviceType = serviceType;
     this.errReporter = errReporter;
     server.Faulted  += delegate
     {
         this.server.Abort();
         this.server = new ServiceHost(serviceType);
         CreateService(server_url, NameSpace, ServiceInterfaceType, MessageCredentialType);
     };
     CreateService(server_url, NameSpace, ServiceInterfaceType, MessageCredentialType);
     server = this.server;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 윈폼 상에서 웹서비스 구축
 /// </summary>
 /// <param name="bindType">바인드 타입</param>
 /// <param name="service">웹서비스로 제공할 객체의 타입 : 싱글톤 타입 안됨</param>
 public soap_WinFormFactory
 (
     ref ServiceHost server,
     Uri server_url,
     string NameSpace,
     Type serviceType,
     Type ServiceInterfaceType,
     ServiceBindingType bindType,
     deleErrReporter errReporter
 )
 {
     this.server      = server;
     this.bindType    = bindType;
     this.service     = null;
     this.serviceType = serviceType;
     this.errReporter = errReporter;
     server.Faulted  += delegate
     {
         this.server.Abort();
         this.server = new ServiceHost(serviceType);
         CreateService(server_url, NameSpace, ServiceInterfaceType);
     };
     CreateService(server_url, NameSpace, ServiceInterfaceType);
     server = this.server;
 }
        private void SetBindingType(ServiceBindingType binding)
        {
            var config = _hogController.GetConfig("DependentTestModule");

            var connectorConfig = config.Root.SubEntries.FirstOrDefault(e => e.Identifier == "SimpleHelloWorldWcfConnector");

            Assert.NotNull(connectorConfig, "Can't get config entry 'SimpleHelloWorldWcfConnector'");

            var hostConfig = connectorConfig.SubEntries.FirstOrDefault(e => e.Identifier == "ConnectorHost");

            Assert.NotNull(hostConfig, "Can't get config entry 'SimpleHelloWorldWcfConnector.ConnectorHost'");

            var bindingType = hostConfig.SubEntries.FirstOrDefault(e => e.Identifier == "BindingType");

            Assert.NotNull(bindingType, "Can't get config entry 'SimpleHelloWorldWcfConnector.ConnectorHost.BindingType'");

            if (bindingType.Value.Current != binding.ToString())
            {
                bindingType.Value.Current = binding.ToString();

                _hogController.SetConfig(config, "DependentTestModule");

                _hogController.StopService("DependentTestModule");
                var result = _hogController.WaitForService("DependentTestModule", ServerModuleState.Stopped, 5);
                Assert.IsTrue(result, "Service '{0}' did not reach state 'Stopped'", "DependentTestModule");

                _hogController.StartService("DependentTestModule");
                result = _hogController.WaitForService("DependentTestModule", ServerModuleState.Running, 5);
                Assert.IsTrue(result, "Service 'DependentTestModule' did not reach state 'Running'");
            }
        }
Exemplo n.º 7
0
 public soap_WinFormFactory(
     ref ServiceHost server,
     Uri server_url,
     string NameSpace,
     Type serviceType,
     Type ServiceInterfaceType,
     ServiceBindingType bindType,
     MessageCredentialType MessageCredentialType,
     string certificatePath,
     string certificatePassword,
     deleErrReporter errReporter
     )
 {
     this.server = server;
     // 인증서 설정
     SetCertificate(certificatePath,certificatePassword);
     this.bindType = bindType;
     this.service = null;
     this.serviceType = serviceType;
     this.errReporter = errReporter;
     server.Faulted += delegate
     {
         this.server.Abort();
         this.server = new ServiceHost(serviceType);
         CreateService(server_url, NameSpace, ServiceInterfaceType, MessageCredentialType);
     };
     CreateService(server_url, NameSpace, ServiceInterfaceType, MessageCredentialType);
     server = this.server;
 }
Exemplo n.º 8
0
        public void TestServiceConfig(string service, string serverVersion, ServiceBindingType binding, string url)
        {
            url = url.Replace("{PORT}", binding == ServiceBindingType.NetTcp ? _hogController.NetTcpPort.ToString() : _hogController.HttpPort.ToString())
                  .Replace("{HOST}", Dns.GetHostName());

            var serviceConfig = _versionService.ServiceEndpoints(service)[0];

            Assert.NotNull(serviceConfig, "ServiceConfig for service {0} not found.", service);

            Assert.AreEqual(serverVersion, serviceConfig.Version);
            Assert.AreEqual(binding, serviceConfig.Binding);
            Assert.AreEqual(url, serviceConfig.Address);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 바인딩을 세팅
        /// </summary>
        /// <param name="messageSecurityType"></param>
        /// <returns></returns>
        protected Binding SetBinding(ServiceBindingType bindType, MessageCredentialType MessageCredentialType)
        {
            Binding bind = null;

            switch (bindType)
            {
            case ServiceBindingType.BasicHttpBinding:
                BasicHttpBinding Basic = new BasicHttpBinding(BasicHttpSecurityMode.Message);
                Basic.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                Basic.MaxBufferPoolSize      = long.MaxValue;
                Basic.MaxBufferSize          = int.MaxValue;
                Basic.MaxReceivedMessageSize = int.MaxValue;
                bind = Basic;
                break;

            case ServiceBindingType.WSHttpBinding:
                WSHttpBinding WSHttp = new WSHttpBinding(SecurityMode.Message);
                WSHttp.Security.Message.ClientCredentialType = MessageCredentialType;
                WSHttp.MaxBufferPoolSize      = int.MaxValue;
                WSHttp.MaxReceivedMessageSize = int.MaxValue;
                bind = WSHttp;
                break;

            case ServiceBindingType.WSDualHttpBinding:
                WSDualHttpBinding WSDualHttp = new WSDualHttpBinding(WSDualHttpSecurityMode.Message);
                WSDualHttp.Security.Message.ClientCredentialType = MessageCredentialType;
                WSDualHttp.MaxBufferPoolSize      = int.MaxValue;
                WSDualHttp.MaxReceivedMessageSize = int.MaxValue;
                bind = WSDualHttp;
                break;

            case ServiceBindingType.NetTcpBinding:
                NetTcpBinding NetTcp = new NetTcpBinding(SecurityMode.Message);
                NetTcp.Security.Message.ClientCredentialType = MessageCredentialType;
                NetTcp.MaxBufferPoolSize      = int.MaxValue;
                NetTcp.MaxBufferSize          = int.MaxValue;
                NetTcp.MaxReceivedMessageSize = int.MaxValue;
                bind = NetTcp;
                break;

            default:
                BasicHttpBinding tmpBind = new BasicHttpBinding(BasicHttpSecurityMode.Message);
                tmpBind.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                tmpBind.MaxBufferPoolSize      = int.MaxValue;
                tmpBind.MaxBufferSize          = int.MaxValue;
                tmpBind.MaxReceivedMessageSize = int.MaxValue;
                bind = tmpBind;
                break;
            }
            return(bind);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates the default binding by type of the binding.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="requiresAuthentication">if set to <c>true</c> [requires authentication].</param>
        /// <param name="proxyConfig">The proxy configuration.</param>
        /// <returns></returns>
        internal static Binding CreateDefault(ServiceBindingType type, bool requiresAuthentication, IProxyConfig proxyConfig)
        {
            switch (type)
            {
            case ServiceBindingType.NetTcp:
                return(CreateDefaultNetTcpBinding());

            case ServiceBindingType.BasicHttp:
                return(CreateDefaultBasicHttpBinding(requiresAuthentication, proxyConfig));

            default:
                return(null);
            }
        }
Exemplo n.º 11
0
 public void AddService(Type service, ServiceBindingType binding, string serviceUrl, ServiceVersionAttribute version, bool requiresAuthentication)
 {
     lock (_services)
     {
         _services[service.Name] = new ServiceConfig
         {
             Binding                = binding,
             ServiceUrl             = serviceUrl,
             ServerVersion          = version.ServerVersion,
             MinClientVersion       = version.MinClientVersion,
             RequiresAuthentication = requiresAuthentication
         };
     }
 }
Exemplo n.º 12
0
        override public void ChangeService(Uri server_url, string NameSpace, ServiceBindingType bindType, Type serviceType, Type InterfaceType)
        {
            //서버가 null일 경우는 그 즉시 생성하여 작업
            if (server == null)
            {
                server = new ServiceHost(serviceType);
            }
            else
            {
                server.Close();
                server = new ServiceHost(serviceType);
            }

            //URL중복 방지
            foreach (Uri url in server.BaseAddresses)
            {
                if (url == server_url)
                {
                    return;
                }
            }

            //HTTPS프로토콜 사용한 URL인지 판단
            bool useHTTPS = false;

            if (((server_url.AbsoluteUri).Replace(" ", string.Empty).Substring(0, 5).ToLower()).Contains("https"))
            {
                useHTTPS = true;
            }

            //웹서비스 Open준비
            try
            {
                //바인딩 설정
                Binding bind = base.SetBinding(bindType);

                //메타데이터 작성
                setMetaData(server, NameSpace, server_url, useHTTPS);
                //Address(A:server_url)Binding(B:bind)Contract(C:service) 설정()
                bind.Namespace = NameSpace;
                server.AddServiceEndpoint(InterfaceType, bind, server_url);
                server.BeginOpen(new AsyncCallback(ServiceBeginOpen_Callback), server);
            }
            catch (Exception ex)
            {
                server.Close();
                server = null;
                throw ex;
            }
        }
Exemplo n.º 13
0
 public SOAPManager(
     ref ServiceHost host,
     SOAPServerType soap_server,
     Uri ServiceURL,
     String NameSpace,
     ServiceBindingType bindType, 
     Type serviceType, 
     Type InterfaceType,
     deleErrReporter errReporter)
 {
     this.errReporter = errReporter;
     switch (soap_server)
     {
         case SOAPServerType.winform:
             SOAPFactory = new soap_WinFormFactory(ref host,ServiceURL,NameSpace,serviceType,InterfaceType,bindType,new deleErrReporter(ThrowErr));
             break;
         case SOAPServerType.WAS:
             break;
         case SOAPServerType.iis:
             break;
         default:
             break;
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// 윈폼 상에서 웹서비스 구축
 /// </summary>
 /// <param name="bindType">바인드 타입</param>
 /// <param name="service">웹서비스로 제공할 객체의 타입 : 싱글톤 타입 안됨</param>
 public soap_WinFormFactory(
     ref ServiceHost server,
     Uri server_url,
     string NameSpace,
     Type serviceType,
     Type ServiceInterfaceType,
     ServiceBindingType bindType,
     deleErrReporter errReporter
     )
 {
     this.server = server;
     this.bindType = bindType;
     this.service = null;
     this.serviceType = serviceType;
     this.errReporter = errReporter;
     server.Faulted += delegate
     {
         this.server.Abort();
         this.server = new ServiceHost(serviceType);
         CreateService(server_url, NameSpace, ServiceInterfaceType);
     };
     CreateService(server_url, NameSpace, ServiceInterfaceType);
     server = this.server;
 }
Exemplo n.º 15
0
        public override void ChangeService(Uri server_url, string NameSpace, ServiceBindingType bindType, object service)
        {
            //서버가 null일 경우는 그 즉시 생성하여 작업
            if (server == null)
            {
                server = new ServiceHost(service);
            }
            else
            {
                server.Close();
                server = new ServiceHost(service);
            }

            //URL중복 방지
            foreach (Uri url in server.BaseAddresses)
            {
                if (url == server_url)
                {
                    return;
                }
            }

            //HTTPS프로토콜 사용한 URL인지 판단
            bool useHTTPS = false;
            if (((server_url.AbsoluteUri).Replace(" ", string.Empty).Substring(0, 5).ToLower()).Contains("https"))
            {
                useHTTPS = true;
            }

            //웹서비스 Open준비
            try
            {
                //바인딩 설정
                Binding bind = base.SetBinding(bindType);
                //메타데이터 작성
                setMetaData(server, NameSpace, server_url, useHTTPS);
                //Address(A:server_url)Binding(B:bind)Contract(C:service) 설정()
                bind.Namespace = NameSpace;
                server.AddServiceEndpoint(service.GetType(), bind, server_url);
                server.BeginOpen(new AsyncCallback(ServiceBeginOpen_Callback), server);
            }
            catch (Exception ex)
            {
                server.Close();
                server = null;
                throw ex;
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// 현재 생성된 서비스를 삭제하고 서비스 다시 구성
 /// </summary>
 /// <param name="server_url">서비스 주소</param>
 /// <param name="NameSpace">네입스페이스</param>
 /// <param name="bindType">바인드 타입</param>
 /// <param name="serviceType">서비스 구상클래스의 타입</param>
 /// <param name="InterfaceType">서비스의 인터페이스 타입</param>
 public void ChangeService(Uri server_url, string NameSpace, ServiceBindingType bindType, Type serviceType, Type InterfaceType)
 {
     SOAPFactory.ChangeService(server_url, NameSpace, bindType, serviceType, InterfaceType);
 }
Exemplo n.º 17
0
 /// <summary>
 /// 현재 생성된 ServiceHost객체를 삭제하고
 /// 다시 생성
 /// </summary>
 /// <param name="server_url"></param>
 /// <param name="NameSpace"></param>
 /// <param name="bindType"></param>
 /// <param name="service">
 ///  서비스로 제공할 객체(싱글톤 객체)
 /// </param>
 public void ChangeService(Uri server_url, string NameSpace, ServiceBindingType bindType, object service)
 {
     SOAPFactory.ChangeService(server_url, NameSpace, bindType, service);
 }
Exemplo n.º 18
0
 /// <summary>
 /// 현재 생성된 ServiceHost객체를 삭제하고
 /// 다시 생성
 /// </summary>
 /// <param name="server_url"></param>
 /// <param name="NameSpace"></param>
 /// <param name="bindType"></param>
 /// <param name="service">
 ///  서비스로 제공할 객체(싱글톤 객체)
 /// </param>
 public void ChangeService(Uri server_url, string NameSpace, ServiceBindingType bindType, object service)
 {
     SOAPFactory.ChangeService(server_url, NameSpace, bindType, service);
 }
Exemplo n.º 19
0
 /// <summary>
 /// 현재 생성된 서비스를 삭제하고 서비스 다시 구성
 /// </summary>
 /// <param name="server_url">서비스 주소</param>
 /// <param name="NameSpace">네입스페이스</param>
 /// <param name="bindType">바인드 타입</param>
 /// <param name="serviceType">서비스 구상클래스의 타입</param>
 /// <param name="InterfaceType">서비스의 인터페이스 타입</param>
 public void ChangeService(Uri server_url, string NameSpace, ServiceBindingType bindType, Type serviceType,Type InterfaceType)
 {
     SOAPFactory.ChangeService(server_url, NameSpace, bindType, serviceType, InterfaceType);
 }