Skip to content

Latest commit

 

History

History
128 lines (93 loc) · 4.47 KB

nc-webservices-ws_service_close_channel_callback.md

File metadata and controls

128 lines (93 loc) · 4.47 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NC:webservices.WS_SERVICE_CLOSE_CHANNEL_CALLBACK
WS_SERVICE_CLOSE_CHANNEL_CALLBACK (webservices.h)
Invoked when a channel is closed or aborted on an endpoint.
WS_SERVICE_CLOSE_CHANNEL_CALLBACK
WS_SERVICE_CLOSE_CHANNEL_CALLBACK callback
WS_SERVICE_CLOSE_CHANNEL_CALLBACK callback function [Web Services for Windows]
webservices/WS_SERVICE_CLOSE_CHANNEL_CALLBACK
wsw.ws_service_close_channel_callback
wsw\ws_service_close_channel_callback.htm
wsw
e2860015-219b-46be-921d-7ced0d95fc60
12/05/2018
WS_SERVICE_CLOSE_CHANNEL_CALLBACK, WS_SERVICE_CLOSE_CHANNEL_CALLBACK callback, WS_SERVICE_CLOSE_CHANNEL_CALLBACK callback function [Web Services for Windows], webservices/WS_SERVICE_CLOSE_CHANNEL_CALLBACK, wsw.ws_service_close_channel_callback
webservices.h
Windows
Windows 7 [desktop apps only]
Windows Server 2008 R2 [desktop apps only]
Windows
19H1
WS_SERVICE_CLOSE_CHANNEL_CALLBACK
webservices/WS_SERVICE_CLOSE_CHANNEL_CALLBACK
c++
APIRef
kbSyntax
UserDefined
WebServices.h
WS_SERVICE_CLOSE_CHANNEL_CALLBACK

WS_SERVICE_CLOSE_CHANNEL_CALLBACK callback function

-description

Invoked when a channel is closed or aborted on an endpoint. This callback is called right before we are about to close the channel.

For normal operation when service host is running and the client cleanly closed the channel, this implies that we have received a session closure from the client and we are about to close the channel.

The other scenario is when service host is going through an Abort Shutdown or during the processing of the message an unrecoverable error condition is met, as a result of this we attempt to abort and then close the channel. In this case as well right before the abort we will call upon this callback.

For session-based service contract, this notification signifies session tear down. Thus an application state scoped for the session can be destroyed within this callback.

-parameters

-param context [in]

The operation context.

-param asyncContext [in, optional]

Information on whether the function is getting invoked asynchronously.

-returns

This callback function does not return a value.

-remarks

The returned HRESULT is only used to see if the function is completing asynchronously. Failure or reporting failure through HRESULT does not in any way affects the service host infrastructure.

Irrespective of whether WS_SERVICE_ACCEPT_CHANNEL_CALLBACK competed successfully or not. This function will always be fired.

See also WS_SERVICE_ACCEPT_CHANNEL_CALLBACK which can be used by the application to associate state, and gets called when a channel gets accepted.

For an example implementation on how to use this callback for disassociating session state, see the session based calculator sample.

This callback is cancellable.

Examples

HRESULT CALLBACK FreeSessionCalculator (const WS_OPERATION_CONTEXT* context,
                                        const WS_ASYNC_CONTEXT* asyncContext)
{
     HRESULT hr = NOERROR;
     SessionfulCalculator* calculator = NULL;
     hr = WsGetOperationContextProperty (context, 
                                         WS_OPERATION_CONTEXT_PROPERTY_CHANNEL_USER_STATE, 
                                         &calculator, sizeof (SessionfulCalculator*), NULL);
     if (SUCCEEDED(hr) && (calculator != NULL))
     {                                                       
         delete calculator;
     }
     return NOERROR;
}