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.