/// <summary>
/// Waits for an asynchronous call to the _NAME_ service to complete.
/// </summary>
    public virtual _NAME_ResponseMessage End_NAME_(IAsyncResult ar)
    {
        try
        {
            IServiceResponse response = ProcessRequestAsyncResult.WaitForComplete(ar, true);
            OnResponseSent(response);
            return(new _NAME_ResponseMessage((_NAME_Response)response));
        }
        catch (Exception e)
        {
            Exception fault = CreateSoapFault(ProcessRequestAsyncResult.GetRequest(ar), e);
            OnResponseFaultSent(fault);
            throw fault;
        }
    }
예제 #2
0
        /// <summary>
        /// Dispatches an incoming binary encoded request.
        /// </summary>
        /// <param name="ar">The ar.</param>
        /// <returns></returns>
        public virtual InvokeServiceResponseMessage EndInvokeService(IAsyncResult ar)
        {
            try {
                // wait for the response.
                IServiceResponse response = ProcessRequestAsyncResult.WaitForComplete(ar, false);

                // encode the repsonse.
                InvokeServiceResponseMessage outgoing = new InvokeServiceResponseMessage();
                outgoing.InvokeServiceResponse = BinaryEncoder.EncodeMessage(response, MessageContext);
                return(outgoing);
            } catch (Exception e) {
                // create fault.
                ServiceFault fault = CreateFault(ProcessRequestAsyncResult.GetRequest(ar), e);

                // encode the fault as a response.
                InvokeServiceResponseMessage outgoing = new InvokeServiceResponseMessage();
                outgoing.InvokeServiceResponse = BinaryEncoder.EncodeMessage(fault, MessageContext);
                return(outgoing);
            }
        }
예제 #3
0
            /// <summary>
            /// Checks for a valid IAsyncResult object and waits for the operation to complete.
            /// </summary>
            /// <param name="ar">The IAsyncResult object for the operation.</param>
            /// <param name="throwOnError">if set to <c>true</c> an exception is thrown if an error occurred.</param>
            /// <returns>The response.</returns>
            public static IServiceResponse WaitForComplete(IAsyncResult ar, bool throwOnError)
            {
                ProcessRequestAsyncResult result = ar as ProcessRequestAsyncResult;

                if (result == null)
                {
                    throw new ArgumentException("End called with an invalid IAsyncResult object.", nameof(ar));
                }

                if (result.m_response == null)
                {
                    if (!result.WaitForComplete())
                    {
                        throw new TimeoutException();
                    }
                }

                if (throwOnError && result.m_error != null)
                {
                    throw new ServiceResultException(result.m_error, StatusCodes.BadInternalError);
                }

                return(result.m_response);
            }
예제 #4
0
 /// <summary>
 /// Ends processing a request received via a binary encoded channel.
 /// </summary>
 /// <param name="result">The result returned by the BeginProcessRequest method.</param>
 /// <returns>
 /// The response to return over the secure channel.
 /// </returns>
 /// <seealso cref="BeginProcessRequest"/>
 public IServiceResponse EndProcessRequest(IAsyncResult result)
 {
     return(ProcessRequestAsyncResult.WaitForComplete(result, false));
 }