Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WsSendFaultMessageForError function

Sends a fault message given a WS_ERROR object.


HRESULT WINAPI  WsSendFaultMessageForError(
  _In_     WS_CHANNEL*             channel,
  _In_     WS_MESSAGE*             replyMessage,
  _In_     WS_ERROR*               faultError,
  _In_     HRESULT                 faultErrorCode,
  _In_     WS_FAULT_DISCLOSURE     faultDisclosure,
  _In_     WS_MESSAGE*             requestMessage,
  _In_opt_ const WS_ASYNC_CONTEXT* asyncContext,
  _In_opt_ WS_ERROR*               error


channel [in]

The channel to send the message on.

replyMessage [in]

A message object to use to send the reply message.

The message object should be in WS_MESSAGE_STATE_EMPTY or WS_MESSAGE_STATE_INITIALIZED. If an initialized message is provided, it should have been initialized using WS_FAULT_MESSAGE.

faultError [in]

The error object to use to construct the fault.

faultErrorCode [in]

The error code associated with the fault. This cannot be a success code.

This error code is never included in the fault message directly, but instead is used as a fallback mechanism for creating an fault string in the case that the WS_ERROR object does not contain any error strings.

faultDisclosure [in]

Controls how much of the error information is included in the fault message.

requestMessage [in]

The request message. This is used to obtain correlation information used in formulating the reply message.

The message can be in any state but WS_MESSAGE_STATE_EMPTY.

asyncContext [in, optional]

Information on how to invoke the function asynchronously, or NULL if invoking synchronously.

error [in, optional]

Specifies where additional error information should be stored if the function fails.

Return value

This function can return one of these values.

Return codeDescription

The asynchronous operation is still pending.


The operation was aborted.


The operation is not allowed due to the current state of the object.


The connection with the remote endpoint was terminated.


The input data was not in the expected format or did not have the expected value.


The operation did not complete within the time allotted.


A quota was exceeded.


Security verification was not successful for the received data.


A security operation failed in the Windows Web Services framework.


Ran out of memory.


One or more arguments are invalid.

Other Errors

This function may return other errors not listed above.



The WS_FAULT that is sent in the body of the message is constructed using the same rules as defined by WsCreateFaultFromError.

The value of the WS_ACTION_HEADER used for the reply message is computed as follows:

If the error object contains a header used to describe the fault as specified by WS_FAULT_ERROR_PROPERTY_HEADER, then the header is added to the headers of the fault message.

The fault message will include correlation information as appropriate to the WS_ADDRESSING_VERSION. See Channel Layer Overview for more information about correlating request reply messages.

If sending a fault without a WS_ERROR object, use WsSendReplyMessage.

To add custom headers to the message, initialize the message WsInitializeMessage with WS_FAULT_MESSAGE and then add the headers using WsAddCustomHeader before calling this function.


Minimum supported client

Windows 7 [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 R2 [desktop apps | UWP apps]









© 2018 Microsoft