Exemplo n.º 1
0
        public static AuthenticationServicePortTypeClient CreateAuthenticationServiceClient(String url, String username, String password)
        {
            if (String.IsNullOrEmpty(url))
            {
                url = "https://localhost:8209/p6ws/services/AuthenticationService";
            }

            var oysterGnetCertificate = GetX509Certificate("oyster.gnet");
            var p6BindingCredentials  = new P6BindingCredentials(username, password);

            p6BindingCredentials.Credentials.TransportCertificate = oysterGnetCertificate;

            //
            // Define our ProjectService client with P6 credentials
            //

            var authenticationServiceClient = new AuthenticationServicePortTypeClient(p6BindingCredentials.Binding, new EndpointAddress(url));

            authenticationServiceClient.ChannelFactory.Endpoint.Behaviors.Remove <ClientCredentials>();
            authenticationServiceClient.ChannelFactory.Endpoint.Behaviors.Add(p6BindingCredentials.Credentials);


            authenticationServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
            authenticationServiceClient.ClientCredentials.ServiceCertificate.Authentication.TrustedStoreLocation      = StoreLocation.LocalMachine;

            authenticationServiceClient.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "oyster.gnet");
            authenticationServiceClient.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "oyster.gnet");


            return(authenticationServiceClient);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the activity service client.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <returns>ActivityPortTypeClient.</returns>
        public static ActivityPortTypeClient CreateActivityServiceClient(String url, String username, String password)
        {
            if (String.IsNullOrEmpty(url))
            {
                url = "https://localhost:8209/p6ws/services/ActivityService";
            }

            var p6BindingCredentials = new P6BindingCredentials(username, password);

            //
            // Define our ProjectService client with P6 credentials
            //
            var activityServiceClient = new ActivityPortTypeClient(p6BindingCredentials.Binding, new EndpointAddress(url));

            activityServiceClient.ChannelFactory.Endpoint.Behaviors.Remove <System.ServiceModel.Description.ClientCredentials>();
            activityServiceClient.ChannelFactory.Endpoint.Behaviors.Add(p6BindingCredentials.Credentials);

            return(activityServiceClient);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the project service client proxy.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <returns>ProjectPortTypeClient.</returns>
        public ProjectPortTypeClient CreateProjectServiceClient(String url, String username, String password)
        {
            if (String.IsNullOrEmpty(url))
            {
                url = "https://localhost:8209/p6ws/services/ProjectService";
            }

            var p6BindingCredentials = new P6BindingCredentials(username, password);

            //
            // Define our ProjectService client with P6 credentials
            //
            var projectServiceClient = new ProjectPortTypeClient(p6BindingCredentials.Binding, new EndpointAddress(url));

            projectServiceClient.ChannelFactory.Endpoint.Behaviors.Remove <System.ServiceModel.Description.ClientCredentials>();
            projectServiceClient.ChannelFactory.Endpoint.Behaviors.Add(p6BindingCredentials.Credentials);

            var cb = new MessageInspectorBehavior();

            // Add the custom behaviour to the list of service behaviours.
            projectServiceClient.Endpoint.Behaviors.Add(cb);

            // Subscribe to message inpection events and provess the event invokation.
            cb.OnMessageInspected += (src, e) =>
            {
                if (e.MessageInspectionType == EMessageInspectionType.Request)
                {
                    WcfRequest = e.Message;
                }
                else
                {
                    WcfResponse = e.Message;
                }
            };


            return(projectServiceClient);
        }