public void Create(
     ManagedObjectReference _this,
     string serviceId,
     LookupServiceRegistrationCreateSpec createSpec)
 {
     this.Channel.Create(_this, serviceId, createSpec);
 }
 public Task CreateAsync(
     ManagedObjectReference _this,
     string serviceId,
     LookupServiceRegistrationCreateSpec createSpec)
 {
     return(this.Channel.CreateAsync(_this, serviceId, createSpec));
 }
Example #3
0
        public void RegisterService(
            string ssoUsername,
            SecureString ssoPassword,
            string nodeId,
            string ownerId,
            string serviceDescriptionResourceKey,
            string serviceId,
            string serviceNameResourceKey,
            string serviceVersion,
            string serviceTypeProduct,
            string serviceTypeType,
            string endpointUrl,
            string endpointProtocol,
            string endpointType,
            X509Certificate2 sslTrustCertificate)
        {
            // Issue Bearer token by user and password fort service registration operation
            var bearerToken = _stsClient.IssueBearerTokenByUserCredential(ssoUsername, ssoPassword);

            // Populate Register Service Spec
            var serviceRegistrationCreateSpec = new LookupServiceRegistrationCreateSpec
            {
                serviceType = new LookupServiceRegistrationServiceType
                {
                    product = serviceTypeProduct,
                    type    = serviceTypeType
                },
                nodeId  = nodeId,
                ownerId = ownerId,
                serviceDescriptionResourceKey = serviceDescriptionResourceKey,
                serviceNameResourceKey        = serviceNameResourceKey,
                serviceVersion   = serviceVersion,
                serviceEndpoints = new[] {
                    new LookupServiceRegistrationEndpoint {
                        url          = endpointUrl,
                        sslTrust     = new[] { Convert.ToBase64String(sslTrustCertificate.RawData) },
                        endpointType = new LookupServiceRegistrationEndpointType {
                            protocol = endpointProtocol,
                            type     = endpointType
                        }
                    }
                }
            };

            // Retrieve Service Content
            var svcContent = _lsClient.RetrieveServiceContentAsync(RootMoRef).Result;

            // Set WS Trust Header Serialization with issued bearer SAML token
            var securityContext = new WsSecurityContext
            {
                ClientChannel = _lsClient.InnerChannel,
                Properties    =
                {
                    Credentials     =
                    {
                        BearerToken = bearerToken
                    }
                }
            };

            // Register Service
            securityContext.InvokeOperation(() => _lsClient.CreateAsync(
                                                svcContent.serviceRegistration,
                                                serviceId,
                                                serviceRegistrationCreateSpec).Wait());
        }