public void Run(string[] args)
        {
            // Relaxes code vocabulary code checks.
            DefaultCodeResolutionConfigurator.ConfigureCodeResolversWithTrivialDefault();

            // a bit of a hack here - we need to force the MR2009 assembly to load into memory
            Assembly.Load("message-builder-release-r02_04_02");

            MessageValidator.Validate(HelloWorldApp.ReadResourceFile("Resources.PRPA_EX101104CA_validation.xml"), HelloWorldApp.MBSpecificationVersion);

            Console.WriteLine("\nDone validation. Press any key to exit.");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        protected string SubmitRequest(IInteraction msg,
                                       CredentialsProvider credentials,
                                       ServiceType serviceType)
        {
            string xmlRequest = this.ConvertMessageObjectToXML(msg);

            xmlRequest = Beautify(xmlRequest);

            Console.WriteLine("\nRequest Message (in XML):\n");
            Console.WriteLine(xmlRequest);

            // Use Message Builder validator to validate the message
            MessageValidator.Validate(xmlRequest, MBSpecificationVersion);

            string xmlResponse = "<null/>";

            switch (serviceType)
            {
            case ServiceType.SIMULATED:
                if (responseExampleResourceFileName != null)
                {
                    Console.WriteLine("Deserializing example XML response from resource bundle: {0}\n", responseExampleResourceFileName);
                    xmlResponse = HelloWorldApp.ReadResourceFile(responseExampleResourceFileName);
                    return(xmlResponse);
                }
                else
                {
                    Console.WriteLine("No example XML response is specified");
                    Environment.Exit(1);
                }
                break;

            case ServiceType.SOAP:
                xmlResponse = this.SubmitSoapServiceRequest(xmlRequest, credentials);
                break;

            case ServiceType.REST:
                xmlResponse = this.SubmitRestServiceRequest(xmlRequest, credentials);
                break;

            default:
                Console.WriteLine("No service type specified in command-line");
                Environment.Exit(1);
                break;
            }

            return(xmlResponse);
        }