MessageParameterAttribute Klas

Definitie

Hiermee bepaalt u de naam van de namen van de aanvraag- en antwoordparameter. Kan niet worden gebruikt met Message of berichtcontracten.

public ref class MessageParameterAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue, Inherited=false)]
public sealed class MessageParameterAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue, Inherited=false)>]
type MessageParameterAttribute = class
    inherit Attribute
Public NotInheritable Class MessageParameterAttribute
Inherits Attribute
Overname
MessageParameterAttribute
Kenmerken

Voorbeelden

In het volgende codevoorbeeld ziet u het gebruik van het instellen van MessageParameterAttribute de naam van de parameter en de retourwaarde in metagegevens.

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Text;

namespace Microsoft.WCF.Documentation
{
  [ServiceContract(Namespace="http://microsoft.wcf.documentation")]
  public interface ISampleService{
    [OperationContract]
    [return:MessageParameter(Name = "Output")]
    string SampleMethod([MessageParameter(Name = "Input")]string msg);
  }

  /*
   The preceding use of MessageParameterAttribute generates the following XSD:

<?xml version="1.0" encoding="utf-8" ?>
  <xs:schema
    elementFormDefault="qualified"
    targetNamespace="http://microsoft.wcf.documentation"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://microsoft.wcf.documentation">
    <xs:element name="SampleMethod">
      <xs:complexType>
        <xs:sequence>
          <xs:element minOccurs="0" name="Input" nillable="true" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    <xs:element name="SampleMethodResponse">
      <xs:complexType>
        <xs:sequence>
          <xs:element minOccurs="0" name="Output" nillable="true" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:schema>

   And the message sent is edited for clarity:
  <s:Body>
    <SampleMethod xmlns="http://microsoft.wcf.documentation">
      <Input>hello!</Input>
    </SampleMethod>
  </s:Body>
   */
Imports System.ServiceModel
Imports System.Text

Namespace Microsoft.WCF.Documentation
  <ServiceContract(Namespace:="http://microsoft.wcf.documentation")> _
  Public Interface ISampleService
    <OperationContract> _
    Function SampleMethod(<MessageParameter(Name := "Input")> ByVal msg As String) As <MessageParameter(Name := "Output")> String
  End Interface

'  
'   The preceding use of MessageParameterAttribute generates the following XSD:
'
'<?xml version="1.0" encoding="utf-8" ?> 
'  <xs:schema 
'    elementFormDefault="qualified" 
'    targetNamespace="http://microsoft.wcf.documentation" 
'    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
'    xmlns:tns="http://microsoft.wcf.documentation">
'    <xs:element name="SampleMethod">
'      <xs:complexType>
'        <xs:sequence>
'          <xs:element minOccurs="0" name="Input" nillable="true" type="xs:string" /> 
'        </xs:sequence>
'      </xs:complexType>
'    </xs:element>
'    <xs:element name="SampleMethodResponse">
'      <xs:complexType>
'        <xs:sequence>
'          <xs:element minOccurs="0" name="Output" nillable="true" type="xs:string" /> 
'        </xs:sequence>
'      </xs:complexType>
'    </xs:element>
'  </xs:schema>
'   
'   And the message sent is edited for clarity:
'  <s:Body>
'    <SampleMethod xmlns="http://microsoft.wcf.documentation">
'      <Input>hello!</Input>
'  </s:Body>   
'

In het volgende voorbeeld ziet u het gegenereerde servicecontract voor de voorgaande service. De naam van de parameter is nu Input.

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://microsoft.wcf.documentation", ConfigurationName="ISampleService")]
public interface ISampleService
{

    [System.ServiceModel.OperationContractAttribute(
      Action="http://microsoft.wcf.documentation/ISampleService/SampleMethod",
      ReplyAction="http://microsoft.wcf.documentation/ISampleService/SampleMethodResponse"
    )]
    [return: System.ServiceModel.MessageParameterAttribute(Name="Output")]
    string SampleMethod(string Input);
}
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute(Namespace:="http://microsoft.wcf.documentation", _
                                             ConfigurationName:="ISampleService")> _
Public Interface ISampleService

    <System.ServiceModel.OperationContractAttribute(Action:="http://microsoft.wcf.documentation/ISampleService/SampleMethod", _
                    ReplyAction:="http://microsoft.wcf.documentation/ISampleService/SampleMethodResponse")> _
    Function SampleMethod(ByVal Input As String) As <System.ServiceModel.MessageParameterAttribute(Name:="Output")> String
End Interface

Opmerkingen

Gebruik de MessageParameterAttribute functie om de naam van de parameter of de retourwaarde te bepalen. Dit kenmerk heeft geen effect als de parameters zijn gemarkeerd door het MessageContractAttribute kenmerk.

Note

De waarde van de parameternamen in de operatiesignatuur maakt deel uit van het contract en is hoofdlettergevoelig. Gebruik dit kenmerk wanneer u onderscheid moet maken tussen de naam van de lokale parameter en de metagegevens waarmee de bewerking voor clienttoepassingen wordt beschreven.

Zie voor meer informatie over het beheren van de serialisatie van de inhoud van een SOAP-hoofdtekst zonder de standaard SOAP-envelop zelf te wijzigen, System.Runtime.Serialization.DataContractAttributehet opgeven van gegevensoverdracht in servicecontracten en het gebruik van gegevenscontracten.

Zie Berichtcontracten gebruiken voor meer informatie over het maken van berichtcontracten.

Constructors

Name Description
MessageParameterAttribute()

Initialiseert een nieuw exemplaar van de MessageParameterAttribute klasse.

Eigenschappen

Name Description
Name

Hiermee wordt het naamkenmerk van de parameter in het XML-schema (XSD) opgehaald of ingesteld.

TypeId

Wanneer deze wordt geïmplementeerd in een afgeleide klasse, krijgt u Attributehiervoor een unieke id.

(Overgenomen van Attribute)

Methoden

Name Description
Equals(Object)

Retourneert een waarde die aangeeft of dit exemplaar gelijk is aan een opgegeven object.

(Overgenomen van Attribute)
GetHashCode()

Retourneert de hash-code voor dit exemplaar.

(Overgenomen van Attribute)
GetType()

Hiermee haalt u de Type huidige instantie op.

(Overgenomen van Object)
IsDefaultAttribute()

Wanneer deze wordt overschreven in een afgeleide klasse, geeft u aan of de waarde van dit exemplaar de standaardwaarde is voor de afgeleide klasse.

(Overgenomen van Attribute)
Match(Object)

Wanneer deze wordt overschreven in een afgeleide klasse, wordt een waarde geretourneerd die aangeeft of dit exemplaar gelijk is aan een opgegeven object.

(Overgenomen van Attribute)
MemberwiseClone()

Hiermee maakt u een ondiepe kopie van de huidige Object.

(Overgenomen van Object)
ToString()

Retourneert een tekenreeks die het huidige object vertegenwoordigt.

(Overgenomen van Object)

Expliciete interface-implementaties

Name Description
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Hiermee wordt een set namen toegewezen aan een bijbehorende set verzend-id's.

(Overgenomen van Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Hiermee haalt u de typegegevens voor een object op, die kan worden gebruikt om de typegegevens voor een interface op te halen.

(Overgenomen van Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Hiermee wordt het aantal type-informatieinterfaces opgehaald dat een object biedt (0 of 1).

(Overgenomen van Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Biedt toegang tot eigenschappen en methoden die door een object worden weergegeven.

(Overgenomen van Attribute)

Van toepassing op