This documentation is archived and is not being maintained.

ContractReference Class

Represents a reference in a discovery document to a service description.


Namespace:  System.Web.Services.Discovery
Assembly:  System.Web.Services (in System.Web.Services.dll)

public class ContractReference : DiscoveryReference

The ContractReference type exposes the following members.

Public methodContractReference()Initializes a new instance of the ContractReference class using default values.
Public methodContractReference(String)Initializes a new instance of the ContractReference class using the supplied reference to a Service Description.
Public methodContractReference(String, String)Initializes a new instance of the ContractReference class using the supplied references to a service description and a XML Web service implementing the service description.

Public propertyClientProtocolGets or sets the instance of DiscoveryClientProtocol used in a discovery process. (Inherited from DiscoveryReference.)
Public propertyContractGets a System.Web.Services.Description.ServiceDescription object representing the service description.
Public propertyDefaultFilenameGets the name of the file to use by default when saving the referenced service description. (Overrides DiscoveryReference.DefaultFilename.)
Public propertyDocRefGets and sets the URL for a XML Web service implementing the service description referenced in the Ref property.
Public propertyRefGets or sets the URL to the referenced service description.
Public propertyUrlGets or sets the URL for the referenced Service Description. (Overrides DiscoveryReference.Url.)

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReadDocumentReads the service description from the passed Stream and returns the service description. (Overrides DiscoveryReference.ReadDocument(Stream).)
Public methodResolve()Downloads the referenced document at Url to resolve whether the referenced document is valid. (Inherited from DiscoveryReference.)
Protected methodResolve(String, Stream)Resolves whether the the referenced document is valid. (Overrides DiscoveryReference.Resolve(String, Stream).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWriteDocumentWrites the passed-in service description into the passed-in Stream. (Overrides DiscoveryReference.WriteDocument(Object, Stream).)

Public fieldStatic memberNamespaceXML namespace for service description references in discovery documents.

XML Web services discovery involves discovering the available Web Services given an URL. The URL usually points to a discovery document, which typically has a.disco file name extension. Within a discovery document are references to information about the existance of XML Web services. These references can refer to service descriptions, XML Schema Definition language (XSD) schemas or other discovery documents. This class represents a reference to a Service Description.

Within a discovery document, a reference to a Service Description is contained within a contractRef XML element. The contractRef XML element has two attributes: ref and docRef. The contractRef element must have an XML namespace matching the Namespace constant, whereas the ref and docRef attributes are placed in the Ref and DocRef properties.

using System;
using System.Xml;
using System.IO;
using System.Web.Services.Discovery;

public class MyContractReference
   static void Main()
         // 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.

         // Add Binding to the references collection.

         // 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);

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.