MessageParameterAttribute.Name Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Obtains or sets the name attribute of the parameter in the XML Schema (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
Property Value
The name attribute of the parameter in the XSD.
Examples
The following code example shows the use of MessageParameterAttribute to establish the name of the parameter and the return value in metadata.
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>
'
The following example shows the generated service contract for the preceding service. Note that the name of the parameter is now 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
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET