次の方法で共有


Metadata Search Browse User Control

Microsoft.ServiceModel.Channels.Tools.MetadataSearchBrowse.MetadataUserControl is a custom System.Windows.Forms.UserControl used within both Add Adapter Service Reference Visual Studio Plug-In and Consume Adapter Service BizTalk Project Add-In. It is available in Microsoft.ServiceModel.Channels.Tools.dll assembly.

namespace Microsoft.ServiceModel.Channels.Tools.MetadataSearchBrowse

{

public class MetadataUserControl : UserControl

{

public MetadataUserControl();

[Browsable(false)]

public System.ServiceModel.Channels.Binding Adapter { get; set; }

public string SecureConnectionUriString { get; }

public ContractType SelectedContractType { get; }

public event EventHandler<AdapterChangedEventArgs> OnAdapterChanged;

public event EventHandler<ConnectionStateChangedEventArgs> OnConnectionStateChanged;

public event EventHandler<MetadataOperationsChangedEventArgs> OnMetadataOperationsChanged;

public event EventHandler<PropertiesEventArgs> OnPropertiesViewed;

protected override void Dispose(bool disposing);

public MetadataRetrievalNode[] GetMetadataOperations();

public ServiceDescription GetWsdl();

}

}

Follow these steps to use this custom metadata user control in your application:

Step 1: Create a Windows Application

Select File > New > Project > Windows > Windows Application

Step 2: Select the Form

Step 3: Add MetadataUserControl to the Toolbox

Select Toolbox > General. Right Click and select “Choose Items…”. In the Filter text box, add “Microsoft.ServiceModel.Channels.Tools”. Select MetadataUserControl. This control should now appear in the toolbox.

Step 4: Drag MetadataUserControl on the form and position/resize accordingly.

Step 5: Customize the form, build and run

Now you can browse (and search) the metadata from your adapter, using the same control that the Add Adapter Service Reference Visual Studio Plug-In and Consume Adapter Service BizTalk Project Add-In tools use.

For example, I added a button called “Generate WSDL” to generate WSDL from the selected operations using MetadataUserControl.GetWsdl method.

Here is the code behind Click event of “Generate WSDL” push button.

public partial class AdapterMetadataExplorer : Form

{

private void btGetWsdl_Click(object sender, EventArgs e)

{

ServiceDescription sd = mdUserControl.GetWsdl();

// write the WSDL to a file

FileStream myFileStream = new FileStream(tbWsdlFileName.Text, FileMode.OpenOrCreate, FileAccess.Write);

StreamWriter myStreamWriter = new StreamWriter(myFileStream);

sd.Write(myStreamWriter);

myStreamWriter.Flush();

myStreamWriter.Close();

MessageBox.Show("WSDL file " + tbWsdlFileName.Text + " is created.");

}

}

See attached ZIP file that contains a Visual Studio Project with a sample windows form application using this custom metadata user control.

ASDK_MetadataExplorer_GetWsdl.zip

Comments

  • Anonymous
    July 08, 2007
    Adapter consumer can browse/search metadata from WCF LOB Adapter using following ways: Using Add Adapter

  • Anonymous
    July 08, 2007
    Add Adapter Service Reference Visual Studio Plug-In generates a CLR objects and Consume Adapter Service

  • Anonymous
    August 10, 2007
    I tried to use the MetadataUserControl, but I simply get this error and the control remains read only: No valid adpaters installed on the machine. I would like to use the control to browse basic WSDL endpoints.  Can this be done? scott_prugh at csgsystems dot com

  • Anonymous
    October 29, 2007
    I installed the WCF LOB Adapter SDK and tried to use it in a vb.net application. When I right click and select the Add Adapter Service Reference. I get the error message "No valid adapters installed on the machine" and then i get the grayed out screen for "Metadata Search Browse User Control". Do i need to have Biztalk server installed to get access to the adapters for Siebel. Thanks, Lionel

  • Anonymous
    March 25, 2008
    I'm trying to use the events for the browser control.  I can get the "OnMetadataOperationsChangedEvent" to work, however, the event below NEVER fires.  Does anyone know if this works?   Thanks: private void OnAdapterChangedEvent(object sender, Microsoft.ServiceModel.Channels.Tools.MetadataSearchBrowse.AdapterChangedEventArgs e)       {               myAadapterName = e.Adapter.Name;       }

  • Anonymous
    March 22, 2012
    Hello Sonu, I am very glad that you have a blog to this, as I am trying to use the Add Service Reference dialog in a wizard. I tried following the above given steps but I am unable to create the MetadataUserControl in my toolbox. I followed step 1 to 3, but the MetadataUserControl never got added to my toolbox. Thanks !!