Ejemplo n.º 1
0
        public Message RequestRespond(Message request)
        {
            DocumentTypeConfigSearcher typeSearcher = new DocumentTypeConfigSearcher();
            OiosiMessage oiosiMessage = new OiosiMessage(request);

            // Use on of the two methods below, to retrive the document

            // This one is very expensive in in time/CPU.
            //XmlDocument xmlDocument = oiosiMessage.MessageXml;

            // This is mutch faster, as not converstion between xml an string is performed
            string xmlDocumentAsString = oiosiMessage.MessageAsString;

            DocumentTypeConfig docTypeConfig = typeSearcher.FindUniqueDocumentType(oiosiMessage.MessageXml);

            // Create the reply message (The body can be empty)
            string responseText;

            try
            {
                string version = ConfigurationHandler.Version;
                responseText = ConfigurationManager.AppSettings["ResponseText"];
                responseText = string.Format(responseText, DateTime.Now.ToString(), version);
            }
            catch (Exception)
            {
                responseText = "Request was received " + DateTime.Now.ToString();
            }

            string  body    = responseText;
            Message message = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, docTypeConfig.EndpointType.ReplyAction, body);

            return(message);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the endpoint key type code from a Message and a
        /// DocumentTypeConfig.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="documentType"></param>
        /// <returns></returns>
        public static string GetEndpointKeyTypeCode(OiosiMessage message, DocumentTypeConfig documentType)
        {
            XmlDocument xmlDocument         = message.MessageXml;
            string      endpointKeyTypeCode = Utilities.GetEndpointKeyTypeCode(xmlDocument, documentType);

            return(endpointKeyTypeCode);
        }
Ejemplo n.º 3
0
        private Identifier getSenderID(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            string senderID = DocumentXPathResolver.GetElementValueByXPathNavigator(
                message.MessageXml,
                docTypeConfig.EndpointType.SenderKey.XPath,
                docTypeConfig.Namespaces);
            var        senderKeyType = Utilities.GetSenderKeyTypeCode(message.MessageXml, docTypeConfig);
            Identifier id            = IdentifierUtility.GetIdentifierFromKeyType(senderID, senderKeyType);

            if (!id.IsAllowedInPublic)
            {
                string cvrNumberString;
                string endpointType;
                if (Credentials.ClientCertificate.TryGetCvrNumberString(out endpointType, out cvrNumberString))
                {
                    id = new Identifier(endpointType, cvrNumberString);
                }
                else
                {
                    throw new Exception("Sender ID is not allowed to be added to header. It was not possible to retrieve ID from certificate");
                }
            }

            return(id);
        }
Ejemplo n.º 4
0
        public void DocumentIdMustBeAddedAsCustomHeader()
        {
            var          documentId   = "678";
            OiosiMessage oiosiMessage = GetInvoiceOiosiMessage();

            // Call private method
            Type                raspRequestType        = typeof(RaspRequest);
            MethodInfo          addCustomHeadersMethod = raspRequestType.GetMethod("AddCustomHeaders", BindingFlags.NonPublic | BindingFlags.Instance);
            OcesX509Certificate client      = new OcesX509Certificate(new X509Certificate2(TestConstants.PATH_CERTIFICATE_EMPLOYEE, TestConstants.PASSWORD_CERTIFICATE_EMPLOYEE));
            OcesX509Certificate server      = new OcesX509Certificate(new X509Certificate2(TestConstants.PATH_CERTIFICATE_EMPLOYEE, TestConstants.PASSWORD_CERTIFICATE_EMPLOYEE));
            Credentials         c1          = new Credentials(client, server);
            RaspRequest         raspRequest = new RaspRequest(new Request(new Uri("http://test.dk"), c1));

            addCustomHeadersMethod.Invoke(raspRequest, new object[] { oiosiMessage, documentId });

            bool headerValueAdded = false;

            foreach (var messageHeader in oiosiMessage.MessageHeaders)
            {
                var headerValue = messageHeader.Value.ToString();
                if (headerValue.Contains(documentId))
                {
                    headerValueAdded = true;
                }
            }
            Assert.IsTrue(headerValueAdded, "DocumentId not found in header.");
        }
Ejemplo n.º 5
0
        public IRaspRequest PrepareRequest(OiosiMessage message, UddiType uddiType)
        {
            // First we need to find out what type of object we are sending
            DocumentTypeConfigSearcher typeSearcher  = new DocumentTypeConfigSearcher();
            DocumentTypeConfig         docTypeConfig = typeSearcher.FindUniqueDocumentType(message.MessageXml);

            // 1. Lookup the endpoint address and certificate using UDDI
            UddiLookupResponse uddiResponse = this.Uddi(message, docTypeConfig);

            // 2. Download the server certificate using LDAP
            X509Certificate2 serverCert = this.Ldap(uddiResponse.CertificateSubjectSerialNumber);

            // 3. Check the validity status of the certificate using OCSP
            this.Revocation(serverCert);


            // 4. Let the user configure the client certificate
            Console.WriteLine("\nPlease configure the certificate used for sending\n----------------------------------------------------");
            X509Certificate2 clientCert  = this.GetCertificate(uddiType);
            Credentials      credentials = new Credentials(new OcesX509Certificate(clientCert), new OcesX509Certificate(serverCert));

            // Create request
            RaspRequest raspRequest = new RaspRequest(new Request(uddiResponse.EndpointAddress.GetAsUri(), credentials));


            return(raspRequest);
        }
Ejemplo n.º 6
0
        private static string GetProfileName(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            string profileName = string.Empty;

            // If doctype does't have a XPath expression to extract the document Profile
            // then we assume that the current document type does operate with OIOUBL profiles

            if (docTypeConfig.ProfileIdXPath == null)
            {
                // no profile
            }
            else if (docTypeConfig.ProfileIdXPath.XPath == null)
            {
                // no profile
            }
            else if (string.IsNullOrEmpty(docTypeConfig.ProfileIdXPath.XPath))
            {
                // no profile
            }
            else
            {
                // Fetch the OIOUBL profile name
                string xPath = docTypeConfig.ProfileIdXPath.XPath;
                PrefixedNamespace[] nameSpaces = docTypeConfig.Namespaces;

                profileName = DocumentXPathResolver.GetElementValueByXPathNavigator(message.MessageXml, xPath, nameSpaces);
            }

            return(profileName);
        }
Ejemplo n.º 7
0
        static LookupParameters GetUddiParameters(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            // Use an OIOSI utility to find the endpoint type in the XML document to be sent
            string endpointKeyTypeCode = Utilities.GetEndpointKeyTypeCode(message, docTypeConfig);

            // Use the XPath expression from the UBL type configuration (found in the RaspConfiguration.xml file)
            // to find the endpoint identifier in the XML document to be sent
            Identifier endpointKey = Utilities.GetEndpointKeyByXpath(
                message.MessageXml,
                docTypeConfig.EndpointType.Key.XPath,
                docTypeConfig.Namespaces,
                endpointKeyTypeCode
                );

            // create the profile tModel
            UddiId profileTModelId = GetProfileTModelId(message, docTypeConfig);

            // Find the UDDI identifier for the service contract used by the remote endpoint
            UddiId serviceContractTModel;

            try {
                serviceContractTModel = IdentifierUtility.GetUddiIDFromString(docTypeConfig.ServiceContractTModel);
            }
            catch (Exception) {
                throw new Exception("Could not find the service contract TModel for the UDDI lookup");
            }

            LookupParameters uddiLookupParameters;

            if (profileTModelId != null)
            {
                // lookup including profile
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <UddiId> {
                    profileTModelId
                },
                    new List <EndpointAddressTypeCode> {
                    EndpointAddressTypeCode.http
                });
            }
            else
            {
                // lookup without profile
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <EndpointAddressTypeCode>()
                {
                    EndpointAddressTypeCode.http
                });
            }

            return(uddiLookupParameters);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Asynchronously starts sending a request
        /// </summary>
        /// <param name="message">Request message</param>
        /// <param name="documentId">The document Id used for the custom headers</param>
        /// <param name="response">The response object</param>
        /// <param name="callback">The asynchronous callback</param>
        /// <returns>Returns an IAsyncResult object</returns>
        public IAsyncResult BeginGetResponse(OiosiMessage message, string documentId, out Response response, AsyncCallback callback)
        {
            // Validate the OiosiMessage
            SendingValidation sendingValidation = new SendingValidation();

            sendingValidation.Validate(message);

            AddCustomHeaders(message, documentId);
            return(this.incapsulatedRequest.BeginGetResponse(message, out response, callback));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Synchronously sends a request and gets a response
        /// </summary>
        /// <param name="request">Request message</param>
        /// <param name="documentId">The document Id used in the MessageIdentifier header</param>
        /// <param name="response">The response. If this parameter is set the sending went well and the response is safe to use</param>
        public void GetResponse(OiosiMessage request, string documentId, out Response response)
        {
            // Validate the OiosiMessage
            SendingValidation sendingValidation = new SendingValidation();

            sendingValidation.Validate(request);

            this.AddCustomHeaders(request, documentId);
            this.incapsulatedRequest.GetResponse(request, out response);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds the MessageIdentifier
        /// </summary>
        /// <param name="msg"></param>
        public static void AddMandatoryRaspHeaders(OiosiMessage msg)
        {
            // Set the name of the header
            XmlQualifiedName headerName = new XmlQualifiedName("MessageIdentifier", common.Definitions.DefaultOiosiNamespace2007);

            // Create a WCF header
            MessageHeader header = MessageHeader.CreateHeader(headerName.Name, headerName.Namespace, "1234567890");

            // Add it to our OIOSI Message
            msg.MessageHeaders.Add(headerName, header);
        }
Ejemplo n.º 11
0
        protected Response SendRequestAndGetResponse(FileInfo file)
        {
            string      documentId  = "TEST:" + Guid.NewGuid();
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(file.FullName);
            OiosiMessage oiosiMessage = new OiosiMessage(xmlDocument);
            RaspRequest  raspRequest  = this.GetRaspRequest(oiosiMessage);
            Response     response;

            raspRequest.GetResponse(oiosiMessage, documentId, out response);
            return(response);
        }
Ejemplo n.º 12
0
        static UddiLookupResponse Uddi(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            UddiConfig uddiConfig = ConfigurationHandler.GetConfigurationSection <UddiConfig>();

            Console.WriteLine("1. UDDI services");

            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine(" Using UDDI/NemHandel register(s):");
            foreach (Registry registry in uddiConfig.LookupRegistryFallbackConfig.PrioritizedRegistryList)
            {
                foreach (string endpoint in registry.Endpoints)
                {
                    Console.WriteLine("  " + endpoint);
                }
            }

            // Create a uddi client
            RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory();

            uddiClient = uddiClientFactory.CreateUddiLookupClient();

            // Get the UDDI parameters with which to call the UDDI server
            LookupParameters parameters = GetUddiParameters(message, docTypeConfig);

            Console.WriteLine(" Lookup Parameters");
            Console.WriteLine("  EndPoint      : " + parameters.Identifier.ToString());
            Console.WriteLine("  EndPoint type : " + parameters.Identifier.KeyTypeCode);
            Console.WriteLine("  Profile       : " + GetProfileName(message, docTypeConfig));

            // Perform the actual UDDI lookup
            UddiLookupResponse uddiResponse = PerformUddiLookup(parameters);

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" Got UDDI reply:");
            Console.ForegroundColor = ConsoleColor.Yellow;

            if (uddiResponse == null)
            {
                Console.WriteLine("  The endpoint is no registrated in UDDI!");
            }
            else
            {
                Console.WriteLine("  " + uddiResponse.EndpointAddress.GetKeyAsString());
            }
            Console.ForegroundColor = ConsoleColor.White;

            return(uddiResponse);
        }
Ejemplo n.º 13
0
        protected LookupParameters GetMessageParameters(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            string endpointKeyTypeCode = Utilities.GetEndpointKeyTypeCode(message, docTypeConfig);

            Identifier endpointKey = Utilities.GetEndpointKeyByXpath(
                message.MessageXml,
                docTypeConfig.EndpointType.Key.XPath,
                docTypeConfig.Namespaces,
                endpointKeyTypeCode
                );

            UddiId profileTModelId = GetProfileTModelId(message, docTypeConfig);

            // 2. Build MessageParameters class:
            UddiId serviceContractTModel;

            serviceContractTModel = IdentifierUtility.GetUddiIDFromString(docTypeConfig.ServiceContractTModel);

            LookupParameters uddiLookupParameters;

            if (profileTModelId == null)
            {
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <EndpointAddressTypeCode>()
                {
                    EndpointAddressTypeCode.http
                });
            }
            else
            {
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <UddiId>()
                {
                    profileTModelId
                },
                    new List <EndpointAddressTypeCode>()
                {
                    EndpointAddressTypeCode.http
                });
            }

            return(uddiLookupParameters);
        }
Ejemplo n.º 14
0
        //static IUddiLookupClient uddiClient;


        private UddiLookupResponse Uddi(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            // Create a uddi client
            RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory();
            IUddiLookupClient           uddiClient        = uddiClientFactory.CreateUddiLookupClient();

            // Get the UDDI parameters with which to call the UDDI server
            LookupParameters parameters = this.GetUddiParameters(message, docTypeConfig);

            // Perform the actual UDDI lookup
            UddiLookupResponse uddiResponse = this.PerformUddiLookup(parameters, uddiClient);

            // Print out info
            Console.Write("\n  1. Got UDDI reply\n       ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(uddiResponse.EndpointAddress.GetKeyAsString());
            Console.ForegroundColor = ConsoleColor.White;

            return(uddiResponse);
        }
Ejemplo n.º 15
0
        protected RaspRequest GetRaspRequest(OiosiMessage oiosiMessage)
        {
            DocumentTypeConfigSearcher documentTypeConfigSearcher = new DocumentTypeConfigSearcher();
            DocumentTypeConfig         documentTypeConfig         = documentTypeConfigSearcher.FindUniqueDocumentType(oiosiMessage.MessageXml);
            LookupParameters           messageParameters          = this.GetMessageParameters(oiosiMessage, documentTypeConfig);
            UddiLookupResponse         uddiResponse = this.PerformUddiLookup(messageParameters);
            Uri endpointAddressUri = uddiResponse.EndpointAddress.GetAsUri();

            OcesX509Certificate endpointCertificate = this.GetEndpointCertificateFromLdap(uddiResponse.CertificateSubjectSerialNumber);

            this.ValidateEndpointCertificate(endpointCertificate);
            //X509Certificate2 clientCertificate = CertificateUtil.InstallAndGetFunctionCertificateFromCertificateStore();
            X509Certificate2 clientCertificate = this.ClientCertificate;

            Credentials credentials = new Credentials(new OcesX509Certificate(clientCertificate), endpointCertificate);
            Request     request     = new Request(endpointAddressUri, credentials);
            RaspRequest raspRequest = new RaspRequest(request);

            return(raspRequest);
        }
Ejemplo n.º 16
0
        protected UddiId GetProfileTModelId(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            UddiId uddiId;

            // If doctype does't have a XPath expression to extract the document Profile
            // then we assume that the current document type does operate with OIOUBL profiles
            if (docTypeConfig.ProfileIdXPath == null)
            {
                uddiId = null;
            }
            else if (docTypeConfig.ProfileIdXPath.XPath == null)
            {
                uddiId = null;
            }
            else if (docTypeConfig.ProfileIdXPath.XPath.Equals(""))
            {
                uddiId = null;
            }
            else
            {
                // Fetch the OIOUBL profile name
                string profileName = DocumentXPathResolver.GetElementValueByXPathNavigator(
                    message.MessageXml,
                    docTypeConfig.ProfileIdXPath.XPath,
                    docTypeConfig.Namespaces);

                ProfileMappingCollectionConfig config = ConfigurationHandler.GetConfigurationSection <ProfileMappingCollectionConfig>();
                if (config.ContainsProfileMappingByName(profileName))
                {
                    ProfileMapping profileMapping    = config.GetMapping(profileName);
                    string         profileTModelGuid = profileMapping.TModelGuid;
                    uddiId = IdentifierUtility.GetUddiIDFromString(profileTModelGuid);
                }
                else
                {
                    throw new Exception("GetProfileTModelId failed for : " + profileName);
                }
            }

            return(uddiId);
        }
Ejemplo n.º 17
0
        private static UddiId GetProfileTModelId(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            UddiId uddiId      = null;
            string profileName = GetProfileName(message, docTypeConfig);

            if (string.IsNullOrEmpty(profileName) == false)
            {
                var config = ConfigurationHandler.GetConfigurationSection <ProfileMappingCollectionConfig>();
                if (config.ContainsProfileMappingByName(profileName))
                {
                    ProfileMapping profileMapping    = config.GetMapping(profileName);
                    string         profileTModelGuid = profileMapping.TModelGuid;
                    uddiId = IdentifierUtility.GetUddiIDFromString(profileTModelGuid);
                }
                else
                {
                    throw new Exception("DocumentProfileMappingNotFoundException: " + profileName);
                }
            }

            return(uddiId);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds custom RASP headers to a given OiosiMessage
        /// </summary>
        /// <param name="message">The message on which the headers should be added</param>
        /// <param name="documentId">The document Id used in the MessageIdentifier header</param>
        private void AddCustomHeaders(OiosiMessage message, string documentId)
        {
            var typeSearcher = new DocumentTypeConfigSearcher();
            DocumentTypeConfig docTypeConfig = typeSearcher.FindUniqueDocumentType(message.MessageXml);

            // Add custom headers to the message
            Identifier senderIdentifier   = getSenderID(message, docTypeConfig);
            Identifier receiverIdentifier = GetReceiverID(message, docTypeConfig);

            string key = PartyIdentifierHeaderSettings.MessagePropertyKey;
            var    partyIdentifierSetting = new PartyIdentifierHeaderSettings(senderIdentifier, receiverIdentifier);

            message.UbiquitousProperties[key] = partyIdentifierSetting;

            // Adds custom headers by xpaths
            foreach (CustomHeaderXPathConfiguration xpath in docTypeConfig.CustomHeaderConfiguration.XPaths)
            {
                var value         = DocumentXPathResolver.GetElementValueByXPathNavigator(message.MessageXml, xpath.XPath, docTypeConfig.Namespaces);
                var qualifiedName = new XmlQualifiedName(xpath.Name, Definitions.DefaultOiosiNamespace2007);
                message.MessageHeaders[qualifiedName] = MessageHeader.CreateHeader(qualifiedName.Name, qualifiedName.Namespace, value);
            }

            // Add the MessageIdentifier header
            var messageIdentifierHeaderName = new XmlQualifiedName("MessageIdentifier", Definitions.DefaultOiosiNamespace2007);

            message.MessageHeaders[messageIdentifierHeaderName] = MessageHeader.CreateHeader(messageIdentifierHeaderName.Name, messageIdentifierHeaderName.Namespace, documentId);

            // Change the SOAP actions
            if (!string.IsNullOrEmpty(docTypeConfig.EndpointType.RequestAction))
            {
                message.RequestAction = docTypeConfig.EndpointType.RequestAction;
            }
            if (!string.IsNullOrEmpty(docTypeConfig.EndpointType.ReplyAction))
            {
                message.ReplyAction = docTypeConfig.EndpointType.ReplyAction;
            }
        }
Ejemplo n.º 19
0
        private LookupParameters GetUddiParameters(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            // Use an OIOSI utility to find the endpoint type in the XML document to be sent
            string endpointKeyTypeCode = Utilities.GetEndpointKeyTypeCode(message, docTypeConfig);

            // Use the XPath expression from the UBL type configuration (found in the RaspConfiguration.xml file)
            // to find the endpoint identifier in the XML document to be sent
            dk.gov.oiosi.addressing.Identifier endpointKey = Utilities.GetEndpointKeyByXpath(
                message.MessageXml,
                docTypeConfig.EndpointType.Key.XPath,
                docTypeConfig.Namespaces,
                endpointKeyTypeCode
                );

            // Find the UDDI identifier for the service contract used by the remote endpoint
            UddiId serviceContractTModel;

            try {
                serviceContractTModel = IdentifierUtility.GetUddiIDFromString(docTypeConfig.ServiceContractTModel);
            }
            catch (Exception) {
                throw new Exception("Could not find the service contract TModel for the UDDI lookup");
            }


            LookupParameters uddiLookupParameters = new LookupParameters(
                endpointKey,
                serviceContractTModel,
                new List <EndpointAddressTypeCode>()
            {
                EndpointAddressTypeCode.http
            });


            return(uddiLookupParameters);
        }
Ejemplo n.º 20
0
        public bool SendDocument()
        {
            // Test logging
            ILogger loggger = LoggerFactory.Create();

            loggger.Info("Logging works.");

            bool result = false;

            try
            {
                // define the RaspConfigurationFile to use
                switch (this.uddiType)
                {
                case UddiType.Production:
                {
                    ConfigurationManager.AppSettings["RaspConfigurationFile"] = "RaspConfiguration.Live.xml";
                    Console.WriteLine("Sending the document through production uddi.");
                    break;
                }

                ////case UddiType.Test:
                ////    {
                ////        ConfigurationManager.AppSettings["RaspConfigurationFile"] = "RaspConfiguration.Test.xml";
                ////        Console.WriteLine("Sending the document through test uddi.");
                ////        break;
                ////    }

                default:
                {
                    throw new NotImplementedException("The uddiType '" + this.uddiType.ToString() + "' not regonized.");
                }
                }

                //CacheConfig v = ConfigurationHandler.GetConfigurationSection<CacheConfig>();

                // Load the document
                XmlDocument xdoc     = new XmlDocument();
                FileInfo    fileInfo = new FileInfo(this.xmlDocumentUrl);

                if (fileInfo.Exists == false)
                {
                    Console.WriteLine("Error - The file does not exist");
                    Console.WriteLine(fileInfo.FullName);
                    // this.Exit();
                    result = false;
                }
                else
                {
                    Console.WriteLine("Start sending the document.");
                    Console.WriteLine(fileInfo.FullName);

                    xdoc.Load(fileInfo.FullName);

                    // Create the OIOSI message object to send, and add the mandatory
                    // MessageIdentifier header
                    OiosiMessage message = new OiosiMessage(xdoc);

                    // Prepare the request

                    Preparation preparation = new Preparation();

                    IRaspRequest request = preparation.PrepareRequest(message, this.uddiType);

                    // Let the user configure his mail account
                    if (request.RequestUri.Scheme == "mailto")
                    {
                        throw new NotImplementedException("Mail sending not implemented - no longer part of RASP.");
                        //GUI.GetMailSettings(request);
                    }

                    // Use the OIOSI library class Request to send the document
                    Console.WriteLine("Starting to send...");
                    Response response;

                    request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                    // Print out the reply
                    GUI.PrintResponse(response);

                    result = true;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
            }

            return(result);
        }
Ejemplo n.º 21
0
 public void GetResponse(OiosiMessage request, out Response response, string documentId)
 {
     this.GetResponse(request, documentId, out response);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="requestMessage">The incoming message</param>
 public ListenerRequest(OiosiMessage requestMessage)
 {
     _requestMessage = requestMessage;
 }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            while (true)
            {
                try {
                    GUI.MenuChoice mode = GUI.DisplayMenu();

                    // Let the user select an XML document to send
                    XmlDocument xdoc = GUI.LoadXmlDocument();
                    Response    response;

                    // Create the OIOSI message object to send, and add the mandatory MessageIdentifier header
                    OiosiMessage message = new OiosiMessage(xdoc);



                    // If the user would like to set proxy config programatically
                    if (mode == GUI.MenuChoice.Custom)
                    {
                        #region 1 - Programatically configured Request

                        // Let the user select a remote endpoint to which the document will be sent
                        Uri endpoint = GUI.GetEndpointAddress();

                        // Let the user select credentials
                        Console.WriteLine("\nPlease configure the certificate used for sending\n----------------------------------------------------");
                        X509Certificate2 clientCert = GUI.GetCertificate();
                        Console.WriteLine("\nPlease configure the certificate used by the remote endpoint\n-------------------------------------------------------------------------");
                        X509Certificate2 serverCert  = GUI.GetCertificate();
                        Credentials      credentials = new Credentials(new OcesX509Certificate(clientCert), new OcesX509Certificate(serverCert));

                        // Create the Request object
                        request = new RaspRequest(new Request(endpoint, credentials));

                        // Let the user configure his mail account
                        if (endpoint.Scheme == "mailto")
                        {
                            GUI.GetMailSettings(request);
                        }

                        // Use the OIOSI library class Request to send the document
                        Console.WriteLine("Starting to send...");

                        request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                        #endregion
                    }

                    // The user would like to use the proxy settings in app.config
                    else
                    {
                        #region 2 - Request configured in App.Config

                        // Use the OIOSI library class Request to send the document
                        Console.WriteLine("Starting to send...");
                        request = new RaspRequest(new Request("OiosiHttpEndpoint"));
                        request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                        #endregion
                    }

                    // Print out the reply
                    GUI.PrintResponse(response);
                }
                catch (Exception e) {
                    GUI.PrintException(e);
                }


                // Ask the user if he wants to send again
                if (!GUI.AskIfRestart())
                {
                    break;
                }

                Console.WriteLine("\n");
            }
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            // Print title
            Console.Title           = "  OIOSI Extended Request Test Application  ";
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.BackgroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("  OIOSI Extended Request Test Application  ");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine();
            Console.WriteLine("Select if the test or the live NemHandel Infrastruktur should be used:");
            Console.Write(" Type 'Live' to use the live system: ");
            string answer = Console.ReadLine();

            if (string.IsNullOrEmpty(answer))
            {
                ConfigurationDocument.ConfigFilePath = "RaspConfiguration.Live.xml";
            }
            else
            {
                if (string.Equals("Live", answer, StringComparison.OrdinalIgnoreCase))
                {
                    ConfigurationDocument.ConfigFilePath = "RaspConfiguration.Live.xml";
                }
                else
                {
                    throw new NotImplementedException();
                }
                ////else
                ////{
                ////    ConfigurationDocument.ConfigFilePath = "RaspConfiguration.Test.xml";
                ////}
            }

            while (true)
            {
                try
                {
                    // Print title
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.BackgroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("  OIOSI Extended Request Test Application  ");
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.WriteLine();

                    if (string.Equals("Live", answer, StringComparison.OrdinalIgnoreCase))
                    {
                        Console.Write("The '");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("Live/Productiv");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write("' NemHandel infrastruktur is used.");
                    }
                    else
                    {
                        Console.Write("The '");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("Test");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write("' NemHandel infrastruktur is used.");
                    }

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine();
                    Console.WriteLine();
                    // Let the user select an XML document to send
                    XmlDocument xdoc = GUI.LoadXmlDocument();

                    // Create the OIOSI message object to send, and add the mandatory MessageIdentifier header
                    OiosiMessage message = new OiosiMessage(xdoc);

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine();
                    Console.WriteLine("File identified - Start preparing");
                    Console.ForegroundColor = ConsoleColor.White;

                    // Prepare the request
                    request = Preparation.PrepareRequest(message);

                    if (request != null)
                    {
                        // Let the user configure his mail account

                        if (request.RequestUri.Scheme == "mailto")
                        {
                            GUI.GetMailSettings(request);
                        }

                        // Use the OIOSI library class Request to send the document
                        Console.WriteLine("Starting to send...");
                        Response response;
                        request.GetResponse(message, Guid.NewGuid().ToString(), out response);

                        // Print out the reply
                        GUI.PrintResponse(response);
                    }
                }
                catch (Exception e) {
                    GUI.PrintException(e);
                }


                // Ask the user if he wants to send again
                if (!GUI.AskIfRestart())
                {
                    break;
                }

                Console.WriteLine("\n");
            }
        }