IWSDDeviceHost::AddDynamicService method (wsdhost.h)

Registers a service object for incoming requests, but does not add the service to the device host metadata. This is used for transient (dynamic) services.

Syntax

HRESULT AddDynamicService(
  [in]           LPCWSTR              pszServiceId,
  [in, optional] LPCWSTR              pszEndpointAddress,
  [in, optional] const WSD_PORT_TYPE  *pPortType,
  [in, optional] const WSDXML_NAME    *pPortName,
  [in, optional] const WSDXML_ELEMENT *pAny,
  [in, optional] IUnknown             *pService
);

Parameters

[in] pszServiceId

The ID for the dynamic service. The service ID must be distinct from all the service IDs in the service host metadata and from any other registered dynamic service. The pszServiceId must be a URI.

[in, optional] pszEndpointAddress

An optional URI to use as the endpoint address for this service. If none is specified, the device host will assume the service should be available on all local transport addresses.

[in, optional] pPortType

Reference to a WSD_PORT_TYPE structure that specifies the port type. May be NULL. Specify only one of pPortType and pPortName.

[in, optional] pPortName

Reference to a WSDXML_NAME structure that specifies the type of the service, with associating the service with a specified port. Specify only one of pPortType and pPortName.

[in, optional] pAny

Optional reference to an extensible section to be included in the dynamic service metadata.

[in, optional] pService

Optional reference to a host service object to register.

Return value

Possible return values include, but are not limited to, the following:

Return code Description
S_OK
Method completed successfully.
E_POINTER
pszServiceId is NULL.
E_INVALIDARG
The length in characters of pszServiceId or pszEndpointAddress exceeds WSD_MAX_TEXT_LENGTH (8192), or both pPortType and pPortName are specified.
E_FAIL
The method failed. It may have failed because the host has not been initialized, or the service specified by pszServiceId could not be found. Call Init to initialize a device host.
E_OUTOFMEMORY
Insufficient memory to complete the operation.

Remarks

When this method is called, the device adds a reference to the service object and calls its methods in response to request messages addressed to the service. Call the RemoveDynamicService method on the device host to release its reference to the service and stop calling methods on the service.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header wsdhost.h (include Wsdapi.h)
DLL Wsdapi.dll

See also

IWSDDeviceHost