MessageContractAttribute.WrapperNamespace 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
메시지 본문 래퍼 요소의 네임스페이스를 가져오거나 설정합니다.
public:
property System::String ^ WrapperNamespace { System::String ^ get(); void set(System::String ^ value); };
public string WrapperNamespace { get; set; }
member this.WrapperNamespace : string with get, set
Public Property WrapperNamespace As String
속성 값
래퍼 요소 네임스페이스입니다.
예제
다음 코드 예제에서는 요청 메시지와 응답 메시지 둘 다에 대한 SOAP 봉투 구조를 제어하는 데 사용하는 MessageContractAttribute 방법과 응답 메시지의 SOAP 헤더를 만들기 위해)와 (요청 및 MessageBodyMemberAttribute 응답 메시지의 본문을 지정하기 위해) 둘 다 MessageHeaderAttribute 사용하는 방법을 보여 줍니다. 코드 예제에는 전송되는 각 메시지의 예제가 포함되어 있습니다.
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
namespace Microsoft.WCF.Documentation
{
[ServiceContract(Namespace = "Microsoft.WCF.Documentation")]
interface IMessagingHello
{
[OperationContract(
Action = "http://GreetingMessage/Action",
ReplyAction = "http://HelloResponseMessage/Action"
)]
HelloResponseMessage Hello(HelloGreetingMessage msg);
}
[MessageContract]
public class HelloResponseMessage
{
private string localResponse = String.Empty;
private string extra = String.Empty;
[MessageBodyMember(
Name = "ResponseToGreeting",
Namespace = "http://www.examples.com")]
public string Response
{
get { return localResponse; }
set { localResponse = value; }
}
[MessageHeader(
Name = "OutOfBandData",
Namespace = "http://www.examples.com",
MustUnderstand=true
)]
public string ExtraValues
{
get { return extra; }
set { this.extra = value; }
}
/*
The following is the response message, edited for clarity.
<s:Envelope>
<s:Header>
<a:Action s:mustUnderstand="1">http://HelloResponseMessage/Action</a:Action>
<h:OutOfBandData s:mustUnderstand="1" xmlns:h="http://www.examples.com">Served by object 13804354.</h:OutOfBandData>
</s:Header>
<s:Body>
<HelloResponseMessage xmlns="Microsoft.WCF.Documentation">
<ResponseToGreeting xmlns="http://www.examples.com">Service received: Hello.</ResponseToGreeting>
</HelloResponseMessage>
</s:Body>
</s:Envelope>
*/
}
[MessageContract]
public class HelloGreetingMessage
{
private string localGreeting;
[MessageBodyMember(
Name = "Salutations",
Namespace = "http://www.examples.com"
)]
public string Greeting
{
get { return localGreeting; }
set { localGreeting = value; }
}
}
/*
The following is the request message, edited for clarity.
<s:Envelope>
<s:Header>
<!-- Note: Some header content has been removed for clarity.
<a:Action>http://GreetingMessage/Action</a:Action>
<a:To s:mustUnderstand="1"></a:To>
</s:Header>
<s:Body u:Id="_0" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<HelloGreetingMessage xmlns="Microsoft.WCF.Documentation">
<Salutations xmlns="http://www.examples.com">Hello.</Salutations>
</HelloGreetingMessage>
</s:Body>
</s:Envelope>
*/
class MessagingHello : IMessagingHello
{
public HelloResponseMessage Hello(HelloGreetingMessage msg)
{
Console.WriteLine("Caller sent: " + msg.Greeting);
HelloResponseMessage responseMsg = new HelloResponseMessage();
responseMsg.Response = "Service received: " + msg.Greeting;
responseMsg.ExtraValues = String.Format("Served by object {0}.", this.GetHashCode().ToString());
Console.WriteLine("Returned response message.");
return responseMsg;
}
}
}
Imports System.Runtime.Serialization
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Namespace Microsoft.WCF.Documentation
<ServiceContract(Namespace := "Microsoft.WCF.Documentation")> _
Friend Interface IMessagingHello
<OperationContract(Action := "http://GreetingMessage/Action", ReplyAction := "http://HelloResponseMessage/Action")> _
Function Hello(ByVal msg As HelloGreetingMessage) As HelloResponseMessage
End Interface
<MessageContract> _
Public Class HelloResponseMessage
Private localResponse As String = String.Empty
Private extra As String = String.Empty
<MessageBodyMember(Name := "ResponseToGreeting", Namespace := "http://www.examples.com")> _
Public Property Response() As String
Get
Return localResponse
End Get
Set(ByVal value As String)
localResponse = value
End Set
End Property
<MessageHeader(Name := "OutOfBandData", Namespace := "http://www.examples.com", MustUnderstand:=True)> _
Public Property ExtraValues() As String
Get
Return extra
End Get
Set(ByVal value As String)
Me.extra = value
End Set
End Property
'
' The following is the response message, edited for clarity.
'
' <s:Envelope>
' <s:Header>
' <a:Action s:mustUnderstand="1">http://HelloResponseMessage/Action</a:Action>
' <h:OutOfBandData s:mustUnderstand="1" xmlns:h="http://www.examples.com">Served by object 13804354.</h:OutOfBandData>
' </s:Header>
' <s:Body>
' <HelloResponseMessage xmlns="Microsoft.WCF.Documentation">
' <ResponseToGreeting xmlns="http://www.examples.com">Service received: Hello.</ResponseToGreeting>
' </s:Body>
' </s:Envelope>
'
End Class
<MessageContract> _
Public Class HelloGreetingMessage
Private localGreeting As String
<MessageBodyMember(Name := "Salutations", Namespace := "http://www.examples.com")> _
Public Property Greeting() As String
Get
Return localGreeting
End Get
Set(ByVal value As String)
localGreeting = value
End Set
End Property
End Class
'
' The following is the request message, edited for clarity.
'
' <s:Envelope>
' <s:Header>
' <!-- Note: Some header content has been removed for clarity.
' <a:Action>http://GreetingMessage/Action</a:Action>
' <a:To s:mustUnderstand="1"></a:To>
' </s:Header>
' <s:Body u:Id="_0" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
' <HelloGreetingMessage xmlns="Microsoft.WCF.Documentation">
' <Salutations xmlns="http://www.examples.com">Hello.</Salutations>
' </s:Body>
' </s:Envelope>
'
Friend Class MessagingHello
Implements IMessagingHello
Public Function Hello(ByVal msg As HelloGreetingMessage) As HelloResponseMessage Implements IMessagingHello.Hello
Console.WriteLine("Caller sent: " & msg.Greeting)
Dim responseMsg As New HelloResponseMessage()
responseMsg.Response = "Service received: " & msg.Greeting
responseMsg.ExtraValues = String.Format("Served by object {0}.", Me.GetHashCode().ToString())
Console.WriteLine("Returned response message.")
Return responseMsg
End Function
End Class
End Namespace
설명
WrapperNamespace 이 속성을 사용하여 래퍼 요소의 네임스페이스를 설정합니다.