views:

7

answers:

0

I'm attempting to write a WCF process that retrieves updates from a number of WWSAPI processes. These could take a number of forms, so I'm using objects as the parameter and return value to make it as generic as possible. However when it gets to the WWSAPI side of things, the object parameter is an empty WS_XML_BUFFER.

All the HRESULTs are S_OK so it definitely appears to be empty on the WWSAPI end, but when I cast the object to a uint in the WCF process (as that was the original type), it succeeds and outputs the number I expected. Any suggestions on what I might be missing for this to happen?

The interface I'm implementing is defined as:

[ServiceContract(Namespace = "http://.../Update", Name = "GetUpdate", ConfigurationName = "GetUpdate")]
public interface IUpdate
{
    [OperationContract]
    object GetUpdate(object Parameters);
}

The C++ code handling the call is as follows:

HRESULT CALLBACK GetUpdate(
    __in const WS_OPERATION_CONTEXT* _context,
    __in_opt WS_XML_BUFFER* Parameters,
    __out_opt WS_XML_BUFFER** GetUpdateResult,
    __in_opt const WS_ASYNC_CONTEXT* _asyncContext,
    __in_opt WS_ERROR* _error)
{
    WS_XML_READER *pReader = NULL;

    HRESULT hr = WsCreateReader(NULL, 0, &pReader, _error);

    hr = WsSetInputToBuffer(pReader, Parameters, NULL, 0, _error);

    BOOL bFound = FALSE;
    hr = WsMoveReader(pReader, WS_MOVE_TO_BOF, &bFound, _error);

    static const ULONG MAX_XML_CHARS = 200;
    WCHAR wszCharBuffer[MAX_XML_CHARS + 1] = {0};
    ULONG nCharsWritten = 0;

    do
    {
        hr = WsReadChars(pReader, wszCharBuffer, MAX_XML_CHARS, &nCharsWritten, _error);
    }
    while (hr == S_OK && nCharsWritten > 0);

    WsFreeReader(pReader);

    return S_OK;
}