280 lines
5.8 KiB
C++
280 lines
5.8 KiB
C++
// <Include>
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT BY HAND.
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// </Include>
|
|
|
|
// <LiteralInclude>
|
|
#include <wsdapi.h>
|
|
// </LiteralInclude>
|
|
|
|
// <LiteralInclude>
|
|
#include "FileService.h"
|
|
// </LiteralInclude>
|
|
|
|
// <LiteralInclude>
|
|
#include "FileServiceTypes.h"
|
|
// </LiteralInclude>
|
|
|
|
// <MessageTypeDeclarations>
|
|
//
|
|
// Port type http://www.example.com/ncd/FileService/FileService
|
|
// Message type declarations
|
|
//
|
|
extern WSDXML_TYPE REQUESTTYPE_GetFileList;
|
|
extern WSDXML_TYPE RESPONSETYPE_GetFileList;
|
|
extern WSDXML_TYPE REQUESTTYPE_GetFile;
|
|
extern WSDXML_TYPE RESPONSETYPE_GetFile;
|
|
extern WSDXML_TYPE RESPONSETYPE_FileChangeEvent;
|
|
|
|
//
|
|
// Port type http://www.example.com/ncd/FileService/FileDevice
|
|
// Message type declarations
|
|
//
|
|
|
|
// </MessageTypeDeclarations>
|
|
|
|
// <HostBuilderImplementation>
|
|
HRESULT CreateFileServiceHost(
|
|
LPCWSTR pszDeviceAddress,
|
|
const WSD_THIS_DEVICE_METADATA* pThisDeviceMetadata,
|
|
IFileService* pIFileService,
|
|
IWSDDeviceHost** ppHostOut,
|
|
IWSDXMLContext** ppContextOut)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
IWSDXMLContext* pContext = NULL;
|
|
IWSDDeviceHost* pHost = NULL;
|
|
|
|
//
|
|
// Validate parameters
|
|
//
|
|
if( NULL == pszDeviceAddress )
|
|
{
|
|
return E_INVALIDARG;
|
|
}
|
|
|
|
if( NULL == pThisDeviceMetadata )
|
|
{
|
|
return E_INVALIDARG;
|
|
}
|
|
|
|
// pIFileService is optional
|
|
if( NULL == ppHostOut )
|
|
{
|
|
return E_POINTER;
|
|
}
|
|
|
|
// ppContextOut is optional
|
|
|
|
*ppHostOut = NULL;
|
|
if( NULL != ppContextOut )
|
|
{
|
|
*ppContextOut = NULL;
|
|
}
|
|
|
|
//
|
|
// Create XML context for namespace and type registration
|
|
//
|
|
hr = WSDXMLCreateContext(&pContext);
|
|
|
|
//
|
|
// Register types used by the service
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = FileServiceRegisterTypes(pContext);
|
|
}
|
|
|
|
//
|
|
// Register namespaces used by the service
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = FileServiceRegisterNamespaces(pContext);
|
|
}
|
|
|
|
//
|
|
// Create device host
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = WSDCreateDeviceHost(pszDeviceAddress, pContext, &pHost);
|
|
}
|
|
|
|
//
|
|
// Register port types
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = pHost->RegisterPortType(&PortType_FileService);
|
|
}
|
|
|
|
//
|
|
// Set metadata
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = pHost->SetMetadata(&thisModelMetadata, pThisDeviceMetadata, &hostMetadata, NULL);
|
|
}
|
|
|
|
//
|
|
// Register services and set discoverability
|
|
//
|
|
if( S_OK == hr && pIFileService != NULL )
|
|
{
|
|
hr = pHost->RegisterService(L"http://www.example.com/ncd/FileService/FileService0", pIFileService);
|
|
}
|
|
|
|
//
|
|
// Cleanup
|
|
//
|
|
if( S_OK == hr && ppContextOut )
|
|
{
|
|
*ppContextOut = pContext;
|
|
}
|
|
else
|
|
{
|
|
if( NULL != pContext )
|
|
{
|
|
pContext->Release();
|
|
}
|
|
}
|
|
|
|
if( S_OK == hr )
|
|
{
|
|
*ppHostOut = pHost;
|
|
}
|
|
else
|
|
{
|
|
if( NULL != pHost )
|
|
{
|
|
pHost->Release();
|
|
}
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
// </HostBuilderImplementation>
|
|
|
|
// <StubDefinitions>
|
|
HRESULT __stdcall
|
|
Stub_GetFileList
|
|
( IUnknown* server
|
|
, IWSDServiceMessaging* service
|
|
, WSD_EVENT* event
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
IFileService* pServer = NULL;
|
|
|
|
RESPONSEBODY_FileService_GetFileList result;
|
|
::ZeroMemory(&result,sizeof(result));
|
|
|
|
hr = server->QueryInterface( __uuidof(IFileService), (void**)&pServer );
|
|
if( S_OK == hr )
|
|
{
|
|
hr =
|
|
pServer->GetFileList
|
|
( &result.parameters
|
|
);
|
|
|
|
pServer->Release();
|
|
pServer = NULL;
|
|
}
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
hr = service->SendResponse(&result,event->Operation,event->MessageParameters);
|
|
}
|
|
if (FAILED(hr))
|
|
{
|
|
hr = service->FaultRequest(&event->Soap->Header,event->MessageParameters, NULL);
|
|
}
|
|
|
|
// Clean up memory from outparams
|
|
if (NULL != result.parameters)
|
|
{
|
|
WSDFreeLinkedMemory( (void*) (result.parameters) );
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
HRESULT __stdcall
|
|
Stub_GetFile
|
|
( IUnknown* server
|
|
, IWSDServiceMessaging* service
|
|
, WSD_EVENT* event
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
IFileService* pServer = NULL;
|
|
|
|
REQUESTBODY_FileService_GetFile* p = reinterpret_cast<REQUESTBODY_FileService_GetFile*>(event->Soap->Body);
|
|
RESPONSEBODY_FileService_GetFile result;
|
|
::ZeroMemory(&result,sizeof(result));
|
|
|
|
hr = server->QueryInterface( __uuidof(IFileService), (void**)&pServer );
|
|
if( S_OK == hr )
|
|
{
|
|
hr =
|
|
pServer->GetFile
|
|
( p->parameters
|
|
, &result.parameters
|
|
);
|
|
|
|
pServer->Release();
|
|
pServer = NULL;
|
|
}
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
hr = service->SendResponse(&result,event->Operation,event->MessageParameters);
|
|
}
|
|
if (FAILED(hr))
|
|
{
|
|
hr = service->FaultRequest(&event->Soap->Header,event->MessageParameters, NULL);
|
|
}
|
|
|
|
// Clean up memory from outparams
|
|
if (NULL != result.parameters)
|
|
{
|
|
WSDFreeLinkedMemory( (void*) (result.parameters) );
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
// </StubDefinitions>
|
|
|
|
// <StubDefinitions>
|
|
HRESULT __stdcall
|
|
Stub_FileChangeEvent
|
|
( IUnknown* server
|
|
, IWSDServiceMessaging* service
|
|
, WSD_EVENT* event
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
IFileServiceEventNotify* pServer = NULL;
|
|
|
|
RESPONSEBODY_FileService_FileChangeEvent* p = reinterpret_cast<RESPONSEBODY_FileService_FileChangeEvent*>(event->Soap->Body);
|
|
|
|
hr = server->QueryInterface( __uuidof(IFileServiceEventNotify), (void**)&pServer );
|
|
if( S_OK == hr )
|
|
{
|
|
pServer->FileChangeEvent
|
|
( p->result
|
|
);
|
|
|
|
pServer->Release();
|
|
pServer = NULL;
|
|
}
|
|
return hr;
|
|
}
|
|
|
|
// </StubDefinitions>
|
|
|