To make a synchronous call to a Microsoft System Center Configuration Manager 2007 endpoint, you use the ISmsMessaging::Invoke Method method. This method takes an XML defined message, and returns, synchronously, an XML blob from a management point endpoint.

The following C++ example shows how to request policy assignments from a management point on the local computer. The example demonstrates how to do the following:

Example

  Copy Code
HRESULT RequestPolicyAssignments()
{
	ISmsMessaging			 *pMessaging = NULL;
	ISmsMessage				 *pRequest = NULL;
	ISmsMessage				 *pReply = NULL;
	WCHAR					 *pszRequestMessage = NULL;
	WCHAR					 *pszReplyMessage = NULL;

	_BEGIN

		// Create root messaging object.
		_CHECKHR( ::CoCreateInstance(
						CLSID_SmsMessaging,
						NULL,
						CLSCTX_INPROC,
						IID_ISmsMessaging,
						(LPVOID*)&pMessaging) );

		// Create message object for the request.
		_CHECKHR( pMessaging->CreateMessage(&pRequest) );

		// Set the target of the message to be the Policy Manager endpoint.
		_CHECKHR( pRequest->SetTargetEndpoint(L"MP_PolicyManager") );

		// Construct a policy assignments request message.
		_CHECKHR( CreatePolicyAssignmentsRequestMessage(&pszRequestMessage) );

		// Set the message body with the request.
		_CHECKHR( pRequest->SetBodyFromString(pszRequestMessage) );

		// Invoke the targeted endpoint on the local computer with the request,
		// and retrieve the reply.
		_CHECKHR( pMessaging->Invoke(NULL, pRequest, &pReply) );

		// Extract body from reply message.
		_CHECKHR( pReply->GetBodyToString(&pszReplyMessage) );

		// Add code to use the reply message.

	_END

	// All cleanup must go after _END block to ensure it gets invoked.

	if(pszReplyMessage)
	{
		::CoTaskMemFree(pszReplyMessage);
}

	if(pReply)
	{
		pReply->Release();
}

	if(pszRequestMessage)
	{
		::CoTaskMemFree(pszRequestMessage);
}

	if(pRequest)
	{
		pRequest->Release();
}

	if(pMessaging)
	{
		pMessaging->Release();
}

	return _RETVAL;
}

Compiling the Code

Configuration Manager 2007 management point interface DLL.

Security

You can set security options for a message by using ISmsMessage4 Interface. For more information, see Configuration Manager Management Point Interface Security.

See Also


Send comments about this topic to Microsoft.