private void CallXxxxApiOperation()
        {
            const string api       = "XxxxClient";
            const string operation = "TestOperation";

            var stopwatch = new System.Diagnostics.Stopwatch();

            stopwatch.Start();

            var request = new TestOperationRequest()
            {
                RequestProp1 = new Prop1()
                {
                    Prop11 = "foo", Prop12 = "bar"
                },
                RequestProp2 = new Prop2()
                {
                    Prop21 = "foo", Prop22 = "bar"
                },
                RequestProp3 = "foo",
                RequestProp4 = "bar"
            };

            LogRequest(api, operation, request);

            System.Threading.Thread.Sleep(2150);
            var response = _xxxxClient.TestOperation(request);

            LogRespons(api, operation, stopwatch, response);
        }
Пример #2
0
        /// <summary>
        /// Initiates the asynchronous execution of the TestOperation operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the TestOperation operation on AmazonRestXMLTestClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndTestOperation
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/test-2014-01-01/TestOperation">REST API Reference for TestOperation Operation</seealso>
        public virtual IAsyncResult BeginTestOperation(TestOperationRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = TestOperationRequestMarshaller.Instance;
            options.ResponseUnmarshaller = TestOperationResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the TestOperation service method.</param>
        ///
        /// <returns>The response from the TestOperation service method, as returned by RestXMLTest.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/test-2014-01-01/TestOperation">REST API Reference for TestOperation Operation</seealso>
        public virtual TestOperationResponse TestOperation(TestOperationRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = TestOperationRequestMarshaller.Instance;
            options.ResponseUnmarshaller = TestOperationResponseUnmarshaller.Instance;

            return(Invoke <TestOperationResponse>(request, options));
        }
        private void LogRequest(string api, string operation, TestOperationRequest request)
        {
            var responsAsJson = _jsonSerializer.ToJson(request, Formatting.Indented);

            using (Serilog.Context.LogContext.PushProperty("Request", responsAsJson, true))
            {
                Log.Here().Information("Request: {@Api} {@Operation}", api, operation);
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the TestOperation service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the TestOperation service method, as returned by RestXMLTest.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/test-2014-01-01/TestOperation">REST API Reference for TestOperation Operation</seealso>
        public virtual Task <TestOperationResponse> TestOperationAsync(TestOperationRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = TestOperationRequestMarshaller.Instance;
            options.ResponseUnmarshaller = TestOperationResponseUnmarshaller.Instance;

            return(InvokeAsync <TestOperationResponse>(request, options, cancellationToken));
        }
        private void LogRequest(string service, string operation, TestOperationRequest request)
        {
            var requestAsXml = _xmlSerializer.ToXml(request);

            using (Serilog.Context.LogContext.PushProperty("Request", requestAsXml, true))
            {
                Log.Here().Information("Request: {@service} {@Operation}", service, operation);
            }
        }
Пример #7
0
        public void EscapedStrings()
        {
            var marshaller = new TestOperationRequestMarshaller();
            var request    = new TestOperationRequest();

            request.ContentLanguage = new List <string>(new[] { "\"English\"", "French,German", "'German'" });

            var internalRequest = marshaller.Marshall(request);

            Assert.IsTrue(internalRequest.Headers.ContainsKey(ExpectedStringHeaderKey));
            Assert.AreEqual("\"English\",\"French,German\",'German'", internalRequest.Headers[ExpectedStringHeaderKey]);
        }
Пример #8
0
        public void Enums()
        {
            var marshaller = new TestOperationRequestMarshaller();
            var request    = new TestOperationRequest();

            request.ContentLanguageEnums = new List <string> {
                LanguageEnum.English, LanguageEnum.French, LanguageEnum.German
            };

            var internalRequest = marshaller.Marshall(request);

            Assert.IsTrue(internalRequest.Headers.ContainsKey(ExpectedEnumHeaderKey));
            Assert.AreEqual("English,French,German", internalRequest.Headers[ExpectedEnumHeaderKey]);
        }
Пример #9
0
 public TestOperationResponse TestOperation(TestOperationRequest request)
 {
     return(new TestOperationResponse()
     {
         ResponseProp1 = new Prop1()
         {
             Prop11 = "foo", Prop12 = "bar"
         },
         ResponseProp2 = new Prop2()
         {
             Prop21 = "foo", Prop22 = "bar"
         },
         ResponseProp3 = "foo",
         ResponseProp4 = "bar"
     });
 }