ContractReference.Contract 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 ServiceDescription 物件,表示服務描述。
public:
property System::Web::Services::Description::ServiceDescription ^ Contract { System::Web::Services::Description::ServiceDescription ^ get(); };
public System.Web.Services.Description.ServiceDescription Contract { get; }
member this.Contract : System.Web.Services.Description.ServiceDescription
Public ReadOnly Property Contract As ServiceDescription
屬性值
ServiceDescription 物件,表示服務描述。
例外狀況
ClientProtocol 屬性為 null
。
Documents 的 ClientProtocol 屬性不包含具有 Url 的 URL 的探索文件。
範例
int main()
{
try
{
// Create the file stream.
FileStream^ discoStream = gcnew FileStream( "Service1_CS.disco",FileMode::Open );
// Create the discovery document.
DiscoveryDocument^ myDiscoveryDocument = DiscoveryDocument::Read( discoStream );
// Get the first ContractReference in the collection.
ContractReference^ myContractReference = dynamic_cast<ContractReference^>(myDiscoveryDocument->References[ 0 ]);
// Set the client protocol.
myContractReference->ClientProtocol = gcnew DiscoveryClientProtocol;
myContractReference->ClientProtocol->Credentials = CredentialCache::DefaultCredentials;
// Get the service description.
ServiceDescription^ myContract = myContractReference->Contract;
// Create the service description file.
myContract->Write( "MyService1.wsdl" );
Console::WriteLine( "The WSDL file created is MyService1.wsdl" );
discoStream->Close();
}
catch ( Exception^ ex )
{
Console::WriteLine( "Exception: {0}", ex->Message );
}
}
class MyClass1
{
static void Main()
{
try
{
// Create the file stream.
FileStream discoStream =
new FileStream("Service1_CS.disco",FileMode.Open);
// Create the discovery document.
DiscoveryDocument myDiscoveryDocument =
DiscoveryDocument.Read(discoStream);
// Get the first ContractReference in the collection.
ContractReference myContractReference =
(ContractReference)myDiscoveryDocument.References[0];
// Set the client protocol.
myContractReference.ClientProtocol = new DiscoveryClientProtocol();
myContractReference.ClientProtocol.Credentials =
CredentialCache.DefaultCredentials;
// Get the service description.
ServiceDescription myContract = myContractReference.Contract;
// Create the service description file.
myContract.Write("MyService1.wsdl");
Console.WriteLine("The WSDL file created is MyService1.wsdl");
discoStream.Close();
}
catch(Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
}
}
Class MyClass1
Shared Sub Main()
Try
' Create the file stream.
Dim discoStream As _
New FileStream("Service1_vb.disco", FileMode.Open)
' Create the discovery document.
Dim myDiscoveryDocument As _
DiscoveryDocument = DiscoveryDocument.Read(discoStream)
' Get the first ContractReference in the collection.
Dim myContractReference As ContractReference = _
CType(myDiscoveryDocument.References(0), ContractReference)
' Set the client protocol.
myContractReference.ClientProtocol = New DiscoveryClientProtocol()
myContractReference.ClientProtocol.Credentials = _
CredentialCache.DefaultCredentials
' Get the service description.
Dim myContract As ServiceDescription = myContractReference.Contract
' Create the service description file.
myContract.Write("MyService1.wsdl")
Console.WriteLine("The WSDL file created is MyService1.wsdl")
discoStream.Close()
Catch ex As Exception
Console.WriteLine("Exception: " + ex.Message)
End Try
End Sub
End Class