本文整理汇总了C#中System.Web.Services.Discovery.ContractReference类的典型用法代码示例。如果您正苦于以下问题:C# ContractReference类的具体用法?C# ContractReference怎么用?C# ContractReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContractReference类属于System.Web.Services.Discovery命名空间,在下文中一共展示了ContractReference类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Xml;
using System.IO;
using System.Web.Services.Discovery;
public class MyContractReference
{
static void Main()
{
try
{
// Get a DiscoveryDocument.
DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();
// Get a ContractReference.
ContractReference myContractReference = new ContractReference();
// Set the URL to the referenced service description.
myContractReference.Ref = "http://localhost/service1.asmx?wsdl";
// Set the URL for an XML Web service implementing the service
// description.
myContractReference.DocRef = "http://localhost/service1.asmx";
SoapBinding myBinding = new SoapBinding();
myBinding.Binding = new XmlQualifiedName("q1:Service1Soap");
myBinding.Address = "http://localhost/service1.asmx";
// Add myContractReference to the list of references contained
// in the discovery document.
myDiscoveryDocument.References.Add(myContractReference);
// Add Binding to the references collection.
myDiscoveryDocument.References.Add(myBinding);
// Open or create a file for writing.
FileStream myFileStream = new FileStream("Service1.disco",
FileMode.OpenOrCreate, FileAccess.Write );
StreamWriter myStreamWriter = new StreamWriter( myFileStream );
// Write myDiscoveryDocument into the passed stream.
myDiscoveryDocument.Write( myStreamWriter );
Console.WriteLine("The Service1.disco is generated.");
}
catch(Exception e)
{
Console.WriteLine("Error is "+ e.Message);
}
}
}