Exemple #1
0
        private static void serialize(UserAuthorisationType type)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(UserAuthorisationType));

            StringBuilder sb = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb))
            {
                serializer.Serialize(writer, type);
            }
            String str = sb.ToString();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                String           path  = Path.Combine(Directory.GetCurrentDirectory(), "TestMOCES1.pfx");
                X509Certificate2 moces = new X509Certificate2(path, "Test1234");

                UserAuthorisationType userAuthorisation = new UserAuthorisationType();
                userAuthorisation.SEIUser                 = new UserAuthorisationTypeSEIUser();
                userAuthorisation.SEIUser.FullName        = "Bent Hansen";
                userAuthorisation.SEIUser.X509Certificate = moces.RawData;
                userAuthorisation.SEIUser.PersonCivilRegistrationIdentifier = "2207712801";
                userAuthorisation.SEIUser.Item            = "*****@*****.**";
                userAuthorisation.SEIUser.ItemElementName = ItemChoiceType.Email;

                userAuthorisation.SEIPlugIn           = new UserAuthorisationTypeSEIPlugIn[2];
                userAuthorisation.SEIPlugIn[0]        = new UserAuthorisationTypeSEIPlugIn();
                userAuthorisation.SEIPlugIn[0].Plugin = "dk.hob.ei.hbs.Plugin";
                userAuthorisation.SEIPlugIn[1]        = new UserAuthorisationTypeSEIPlugIn();
                userAuthorisation.SEIPlugIn[1].Plugin = "dk.hob.ei.ivf.Plugin";

                serialize(userAuthorisation);

                UserAdministration.UserAdministration service = new UserAdministration.UserAdministration();
                service.SetPolicy(new DGWSPolicy(moces));

                bool b = service.AuthoriseUser(userAuthorisation);

                System.Diagnostics.Debug.WriteLine(b);
            }
            catch (SoapHeaderException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            catch (SoapException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }