335 lines
7.9 KiB
C++
335 lines
7.9 KiB
C++
// <Include>
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// This file is automatically generated. However, the file needs to be
|
|
// modified in order to accomodate changes needed for for the device host
|
|
// creation to use WSDCreateDeviceHost2 instead with customized parameters,
|
|
// or for the device proxy creation to use WSDCreateDeviceProxy2 instead with
|
|
// customized parameters.
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// </Include>
|
|
|
|
// <LiteralInclude>
|
|
#include <wsdapi.h>
|
|
// </LiteralInclude>
|
|
|
|
// <LiteralInclude>
|
|
#include "FileServiceSecure.h"
|
|
// </LiteralInclude>
|
|
|
|
// <LiteralInclude>
|
|
#include "FileServiceSecureTypes.h"
|
|
// </LiteralInclude>
|
|
|
|
// <MessageTypeDeclarations>
|
|
//
|
|
// Port type http://www.example.com/ncd/FileServiceSecure/FileServiceSecure
|
|
// 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/FileServiceSecure/FileDeviceSecure
|
|
// Message type declarations
|
|
//
|
|
|
|
// </MessageTypeDeclarations>
|
|
|
|
// <HostBuilderImplementation>
|
|
HRESULT CreateFileServiceSecureHost(
|
|
BOOL fIsCertAuth,
|
|
BOOL fIsHttpAuth,
|
|
BOOL fIsCertOrHttpAuth,
|
|
LPCWSTR pszDeviceAddress,
|
|
const WSD_THIS_DEVICE_METADATA* pThisDeviceMetadata,
|
|
IFileServiceSecureService* pIFileServiceSecureService,
|
|
IWSDDeviceHost** ppHostOut,
|
|
IWSDXMLContext** ppContextOut)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
IWSDXMLContext* pContext = NULL;
|
|
IWSDDeviceHost* pHost = NULL;
|
|
|
|
//
|
|
// We will have a maximum of 3 configuration parameters, one for each
|
|
// of the authentication modes specified.
|
|
//
|
|
WSD_CONFIG_PARAM configParams[3];
|
|
DWORD dwParamIndex = 0;
|
|
DWORD dwNegotiateScheme = WSD_SECURITY_HTTP_AUTH_SCHEME_NEGOTIATE;
|
|
|
|
::ZeroMemory(configParams, sizeof(configParams));
|
|
|
|
//
|
|
// Validate parameters
|
|
//
|
|
if( NULL == pszDeviceAddress )
|
|
{
|
|
return E_INVALIDARG;
|
|
}
|
|
|
|
if( NULL == pThisDeviceMetadata )
|
|
{
|
|
return E_INVALIDARG;
|
|
}
|
|
|
|
// pIFileServiceSecureService is optional
|
|
if( NULL == ppHostOut )
|
|
{
|
|
return E_POINTER;
|
|
}
|
|
|
|
// ppContextOut is optional
|
|
|
|
*ppHostOut = NULL;
|
|
if( NULL != ppContextOut )
|
|
{
|
|
*ppContextOut = NULL;
|
|
}
|
|
|
|
//
|
|
// Populate the configuration parameters.
|
|
//
|
|
if ( fIsCertAuth )
|
|
{
|
|
configParams[dwParamIndex].configParamType =
|
|
WSD_SECURITY_SSL_NEGOTIATE_CLIENT_CERT;
|
|
configParams[dwParamIndex].pConfigData = NULL;
|
|
configParams[dwParamIndex].dwConfigDataSize = 0;
|
|
|
|
dwParamIndex++;
|
|
}
|
|
|
|
if ( fIsHttpAuth )
|
|
{
|
|
configParams[dwParamIndex].configParamType =
|
|
WSD_SECURITY_REQUIRE_HTTP_CLIENT_AUTH;
|
|
configParams[dwParamIndex].pConfigData = &dwNegotiateScheme;
|
|
configParams[dwParamIndex].dwConfigDataSize = sizeof(dwNegotiateScheme);
|
|
|
|
dwParamIndex++;
|
|
}
|
|
|
|
if ( fIsCertOrHttpAuth )
|
|
{
|
|
configParams[dwParamIndex].configParamType =
|
|
WSD_SECURITY_REQUIRE_CLIENT_CERT_OR_HTTP_CLIENT_AUTH;
|
|
configParams[dwParamIndex].pConfigData = &dwNegotiateScheme;
|
|
configParams[dwParamIndex].dwConfigDataSize = sizeof(dwNegotiateScheme);
|
|
|
|
dwParamIndex++;
|
|
}
|
|
|
|
//
|
|
// Create XML context for namespace and type registration
|
|
//
|
|
hr = WSDXMLCreateContext(&pContext);
|
|
|
|
//
|
|
// Register types used by the service
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = FileServiceSecureRegisterTypes(pContext);
|
|
}
|
|
|
|
//
|
|
// Register namespaces used by the service
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = FileServiceSecureRegisterNamespaces(pContext);
|
|
}
|
|
|
|
//
|
|
// Create device host
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = WSDCreateDeviceHost2(pszDeviceAddress, pContext,
|
|
dwParamIndex > 0 ? configParams : NULL, dwParamIndex, &pHost);
|
|
}
|
|
|
|
//
|
|
// Register port types
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = pHost->RegisterPortType(&PortType_FileServiceSecure);
|
|
}
|
|
|
|
//
|
|
// Set metadata
|
|
//
|
|
if( S_OK == hr )
|
|
{
|
|
hr = pHost->SetMetadata(&thisModelMetadata, pThisDeviceMetadata, &hostMetadata, NULL);
|
|
}
|
|
|
|
//
|
|
// Register services and set discoverability
|
|
//
|
|
if( S_OK == hr && pIFileServiceSecureService != NULL )
|
|
{
|
|
hr = pHost->RegisterService(L"http://www.example.com/ncd/FileServiceSecure/FileServiceSecure0", pIFileServiceSecureService);
|
|
}
|
|
|
|
//
|
|
// 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;
|
|
IFileServiceSecureService* pServer = NULL;
|
|
|
|
RESPONSEBODY_FileServiceSecure_GetFileList result;
|
|
::ZeroMemory(&result,sizeof(result));
|
|
|
|
hr = server->QueryInterface( __uuidof(IFileServiceSecureService), (void**)&pServer );
|
|
if( S_OK == hr )
|
|
{
|
|
hr =
|
|
pServer->GetFileList
|
|
( event
|
|
, &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;
|
|
IFileServiceSecureService* pServer = NULL;
|
|
|
|
REQUESTBODY_FileServiceSecure_GetFile* p = reinterpret_cast<REQUESTBODY_FileServiceSecure_GetFile*>(event->Soap->Body);
|
|
RESPONSEBODY_FileServiceSecure_GetFile result;
|
|
::ZeroMemory(&result,sizeof(result));
|
|
|
|
hr = server->QueryInterface( __uuidof(IFileServiceSecureService), (void**)&pServer );
|
|
if( S_OK == hr )
|
|
{
|
|
hr =
|
|
pServer->GetFile
|
|
( event
|
|
, 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
|
|
)
|
|
{
|
|
UNREFERENCED_PARAMETER(service);
|
|
|
|
HRESULT hr = S_OK;
|
|
IFileServiceSecureEventNotify* pServer = NULL;
|
|
|
|
RESPONSEBODY_FileServiceSecure_FileChangeEvent* p = reinterpret_cast<RESPONSEBODY_FileServiceSecure_FileChangeEvent*>(event->Soap->Body);
|
|
|
|
hr = server->QueryInterface( __uuidof(IFileServiceSecureEventNotify), (void**)&pServer );
|
|
if( S_OK == hr )
|
|
{
|
|
pServer->FileChangeEvent
|
|
( p->result
|
|
);
|
|
|
|
pServer->Release();
|
|
pServer = NULL;
|
|
}
|
|
return hr;
|
|
}
|
|
|
|
// </StubDefinitions>
|
|
|