MessageParameterAttribute.Name Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define o atributo de nome do parâmetro no esquema XML (XSD).
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
Valor da propriedade
O atributo de nome do parâmetro no XSD.
Exemplos
O exemplo de código a seguir mostra o uso para MessageParameterAttribute estabelecer o nome do parâmetro e o valor de retorno em metadados.
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>
'
O exemplo a seguir mostra o contrato de serviço gerado para o serviço anterior. Observe que o nome do parâmetro agora 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