本文整理匯總了C#中System.ServiceModel.Description.MetadataResolver類的典型用法代碼示例。如果您正苦於以下問題:C# MetadataResolver類的具體用法?C# MetadataResolver怎麽用?C# MetadataResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MetadataResolver類屬於System.ServiceModel.Description命名空間,在下文中一共展示了MetadataResolver類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: if
// Get the endpoints for such a service
ServiceEndpointCollection endpoints = MetadataResolver.Resolve(typeof(SampleServiceClient), metaAddress);
Console.WriteLine("Trying all available WS-Transfer metadata endpoints...");
foreach (ServiceEndpoint point in endpoints)
{
if (point != null)
{
// Create a new wcfClient using retrieved endpoints.
wcfClient = new SampleServiceClient(point.Binding, point.Address);
Console.WriteLine(
wcfClient.SampleMethod("Client used the "
+ point.Address.ToString()
+ " address.")
);
wcfClient.Close();
}
}
示例2: if
// Get the endpoints for such a service using Http/Get request
endpoints = MetadataResolver.Resolve(typeof(SampleServiceClient), httpGetMetaAddress.Uri, MetadataExchangeClientMode.HttpGet);
Client.WriteParameters(endpoints);
ISampleService serviceChannel;
Console.WriteLine(
"\r\nTrying all endpoints from HTTP/Get and with direct service channels...");
foreach (ServiceEndpoint point in endpoints)
{
if (point != null)
{
ChannelFactory<ISampleService> factory = new ChannelFactory<ISampleService>(point.Binding);
factory.Endpoint.Address = point.Address;
serviceChannel = factory.CreateChannel();
Console.WriteLine("Client used the " + point.Address.ToString() + " address.");
Console.WriteLine(
serviceChannel.SampleMethod(
"Client used the " + point.Address.ToString() + " address."
)
);
factory.Close();
}
}