Condividi tramite


How to Create or Remove a Connector by Using the OMCF Web Service

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

You can use the Operations Manager Connector Framework (OMCF) Web service to create a connector that allows Operations Manager to communicate with an external system.

Note

If the external system runs on a Windows-based computer, using the class libraries is the preferred method for creating the connector. For more information, see How to Create or Remove a Connector by Using the Operations Manager Class Libraries.

Example

The following example demonstrates how to create and remove a connector using the OMCF Web service. Before creating a connector, you can create an OMCF Web service proxy. For more information, see How to Create an OMCF Web Service Proxy.

/// <summary>
/// Creates and removes a new connector by using the OMCF Web service.
/// </summary>
using System;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.ConnectorFramework;
using System.IO;
using System.Text;
using System.Xml;

namespace SDKSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementGroup mg = new ManagementGroup("localhost");

            Guid connectorId = Guid.NewGuid();

            // Create a new connector.
            ConnectorInfo myConnectorInfo = new ConnectorInfo();
            myConnectorInfo.Name = "myConnector";
            myConnectorInfo.DisplayName = "My Connector";
            myConnectorInfo.Description = "This connector was created using the OMCF Web service.";

            // Define the Web service URI endpoint address for the Web service
            // that is used to create the connector.
            string uriEndpointAddress = "EnterURIEndpointAddressHere";
            ConnectorFrameworkProxy OMCFProxy =
                new ConnectorFrameworkProxy(uriEndpointAddress);

            OMCFProxy.SetupWithConnectorId(myConnectorInfo, connectorId);
            OMCFProxy.Initialize(connectorId);

            Console.WriteLine("Created " + myConnectorInfo.Name +
                " with ID: " + connectorId.ToString());


            // Remove the connector.
            Console.WriteLine("Removing connector with Id: " + connectorId);
            OMCFProxy.Uninitialize(connectorId);
            OMCFProxy.Cleanup(connectorId);
            Console.WriteLine("Connector removed.");

        }
    }
}
' Creates and removes a new connector by using the OMCF Web service.
Imports System
Imports System.Collections.ObjectModel
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.ConnectorFramework
Imports System.IO
Imports System.Text
Imports System.Xml

Namespace SDKSamples
    Class Program
        Public Overloads Shared Function Main(ByVal args() As String) As Integer

            Dim mg As ManagementGroup = New ManagementGroup("localhost")

            Dim connectorId As Guid = Guid.NewGuid()

            ' Create a new connector.
            Dim myConnectorInfo As ConnectorInfo = New ConnectorInfo()
            myConnectorInfo.Name = "myConnector"
            myConnectorInfo.DisplayName = "My Connector"
            myConnectorInfo.Description = "This connector was created using the OMCF Web service."

            ' Define the Web service URI endpoint address for the Web service
            ' that is used to create the connector.
            Dim uriEndpointAddress As String = "EnterURIEndpointAddressHere"
            Dim OMCFProxy As ConnectorFrameworkProxy = _
                New ConnectorFrameworkProxy(uriEndpointAddress)

            OMCFProxy.SetupWithConnectorId(myConnectorInfo, connectorId)
            OMCFProxy.Initialize(connectorId)

            Console.WriteLine("Created " & myConnectorInfo.Name & _
                " with ID: " & connectorId.ToString())

            ' Remove the connector.
            Console.WriteLine("Removing connector with Id: " & connectorId.ToString())
            OMCFProxy.Uninitialize(connectorId)
            OMCFProxy.Cleanup(connectorId)
            Console.WriteLine("Connector removed.")

        End Function
    End Class
End Namespace

See Also

Tasks

How to Create or Remove a Connector by Using the Operations Manager Class Libraries
How to Create an OMCF Web Service Proxy