public static string getCompanyInfoWithActas(BootstrapContext token, int userCvr) { var serviceToken = GetTokenForActasWithCertificate(token); // Lav binding til STS'en var stsBinding = WsTrustClient.GetStsBinding(); // Lav binding til servicen var serviceBinding = WsTrustClient.GetServiceBinding(stsBinding, Constants.StsAddressUserName, true); // Lav channel til servicen var channelFactory = new ChannelFactory <IService1>(serviceBinding, Constants.PocServiceEndpoint);//different from serviceURL if (channelFactory.Credentials == null) { throw new ApplicationException("ChannelFactory must have credentials"); } // Deaktiver service cert validering channelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; channelFactory.Credentials.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; // Påhæft token til kald til service var channel = channelFactory.CreateChannelWithActAsToken(serviceToken); try { var msg = channel.GetCompanyByCvrNumber(userCvr); return(msg.Name); } catch (Exception ex) { var msg = ex.Message; return(msg); } finally { WsTrustClient.CloseChannel(channel); } }