WS_SERVICE_MESSAGE_RECEIVE_CALLBACK callback function (webservices.h)
Invoked when a WS_MESSAGE is received on an endpoint configured with a WS_SERVICE_CONTRACT which has defaultMessageHandlerCallback set.
The incoming WS_MESSAGE, the serviceProxy along with other parameters is made available to the callback through WS_OPERATION_CONTEXT.
Syntax
WS_SERVICE_MESSAGE_RECEIVE_CALLBACK WsServiceMessageReceiveCallback;
HRESULT WsServiceMessageReceiveCallback(
[in] const WS_OPERATION_CONTEXT *context,
[in, optional] const WS_ASYNC_CONTEXT *asyncContext,
[in, optional] WS_ERROR *error
)
{...}
Parameters
[in] context
The context within which this callback is being invoked.
[in, optional] asyncContext
Specifies whether the callback can run asynchronously.
[in, optional] error
Specifies where additional error information should be stored if the function fails.
Return value
This callback function does not return a value.
Remarks
When defined, callback would disallow all concurrency on a session based channel. If concurrency on a session based channel is desirable an application should not define WS_SERVICE_MESSAGE_RECEIVE_CALLBACK on the WS_SERVICE_CONTRACT.
At the time of the invocation of the callback, service model has performed WsReadMessageStart on the receiving WS_MESSAGE. It is the responsibility of the application implementing WS_SERVICE_MESSAGE_RECEIVE_CALLBACK to process the body and perform WsReadMessageEnd operation.
If the callback fails, the underlying channel is aborted.
See also, UnTypedServiceExample
Examples
Defining a WS_SERVICE_MESSAGE_RECEIVE_CALLBACK
// Method contract for the service
static WS_SERVICE_CONTRACT calculatorContract =
{
NULL,
NULL,
DefaultMessageHandlerCallback, // WS_SERVICE_MESSAGE_RECEIVE_CALLBACK
NULL
};
Accessing the incoming WS_MESSAGE property
HRESULT CALLBACK MessageRecieved(const WS_OPERATION_CONTEXT* context, const WS_ASYNC_CONTEXT* asyncContext, WS_ERROR* error)
{
:
hr = WsGetOperationContextProperty(context, WS_OPERATION_CONTEXT_PROPERTY_INPUT_MESSAGE, &requestMessage, sizeof(requestMessage), NULL, error);
:
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 R2 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | webservices.h |