Compartir a través de


ServiceContractAttribute.Name Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the name for the <portType> element in Web Services Description Language (WSDL).

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Public Property Name As String
public string Name { get; set; }

Property Value

Type: System.String
The default value is the name of the class or interface to which the ServiceContractAttribute is applied.

Exceptions

Exception Condition
ArgumentNullException

The value is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

The value is an empty string.

Remarks

Use the Name and the Namespace properties to control the name and namespace of the <portType> element in WSDL.

Examples

    'The following code contains an example of a duplex contract that contains a callback contract.
    <ServiceContract(Name := "SampleContract", Namespace := "Silverlight", CallbackContract := GetType(IDuplexClient))> _
    Public Interface IDuplexService
        <OperationContract(IsOneWay := True)> _
        Sub Order(ByVal name As String, ByVal quantity As Integer)
    End Interface

    <ServiceContract> _
    Public Interface IDuplexClient
        <OperationContract(IsOneWay := True)> _
        Sub Receive(ByVal order As Order)
    End Interface
//The following code contains an example of a duplex contract that contains a callback contract.
[ServiceContract(
    Name = "SampleContract", 
    Namespace = "Silverlight", 
    CallbackContract = typeof(IDuplexClient))]
public interface IDuplexService
{
    [OperationContract(IsOneWay = true)]
    void Order(string name, int quantity);
}

[ServiceContract]
public interface IDuplexClient
{
    [OperationContract(IsOneWay = true)]
    void Receive(Order order);
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.