래핑 해제 샘플은 래핑되지 않은 메시지를 보여 줍니다. 기본적으로 메시지 본문은 서비스 작업에 대한 매개 변수가 래핑되도록 형식이 지정됩니다. 다음 샘플은 래핑된 모드에서 Add
요청 메시지를 ICalculator
서비스에 보내는 것을 보여줍니다.
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://schemas.xmlsoap.org/ws/2005/08/addressing">
<s:Header>
…
</s:Header>
<s:Body>
<Add xmlns="http://Microsoft.ServiceModel.Samples">
<n1>100</n1>
<n2>15.99</n2>
</Add>
</s:Body>
</s:Envelope>
<Add>
메시지 본문의 요소는 n1
및 n2
매개 변수를 래핑합니다. 반면, 다음 샘플에서는 래핑 해제 모드에서 해당 메시지를 보여 둡니다.
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://schemas.xmlsoap.org/ws/2005/08/addressing">
<s:Header>
….
</s:Header>
<s:Body>
<n1 xmlns="http://Microsoft.ServiceModel.Samples">100</n1>
<n2 xmlns="http://Microsoft.ServiceModel.Samples">15.99</n2>
</s:Body>
</s:Envelope>
래핑이 해제된 메시지는 n1
및 n2
매개 변수를 포함 요소로 래핑하지 않고, soap 본문 요소의 직접 자식으로 있습니다.
비고
이 샘플에 대한 설치 절차 및 빌드 지침은 이 항목의 끝에 있습니다.
이 샘플에서는 서비스 작업 매개 변수 형식과 반환 값 형식에 MessageContractAttribute를 적용하여 감싸지 않은 메시지를 생성합니다. 다음 샘플 코드와 같이 처리됩니다.
[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")]
public interface ICalculator
{
[OperationContract]
ResponseMessage Add(RequestMessage request);
[OperationContract]
ResponseMessage Subtract(RequestMessage request);
[OperationContract]
ResponseMessage Multiply(RequestMessage request);
[OperationContract]
ResponseMessage Divide(RequestMessage request);
}
//setting IsWrapped to false means the n1 and n2
//members will be direct children of the soap body element
[MessageContract(IsWrapped = false)]
public class RequestMessage
{
[MessageBodyMember]
private double n1;
[MessageBodyMember]
private double n2;
//…
}
//setting IsWrapped to false means the result
//member will be a direct child of the soap body element
[MessageContract(IsWrapped = false)]
public class ResponseMessage
{
[MessageBodyMember]
private double result;
//…
}
보내고 받는 메시지를 볼 수 있도록 이 샘플에서는 추적을 사용합니다. 또한 기록되는 WSHttpBinding 메시지 수를 줄이기 위해 보안 없이 구성되었습니다.
결과 추적 로그(c:\logs\Message.log)는 서비스 추적 뷰어 도구(SvcTraceViewer.exe)를 사용하여 볼 수 있습니다. 메시지 내용을 보려면 서비스 추적 뷰어 도구의 왼쪽 창과 오른쪽 창에서 메시지를 선택합니다. 이 샘플의 추적 로그는 C:\LOGS 폴더에 생성되도록 구성됩니다. 샘플을 실행하기 전에 이 폴더를 만들고 사용자에게 이 디렉터리에 대한 쓰기 권한을 부여합니다.
샘플을 설정, 빌드 및 실행하려면
Windows Communication Foundation 샘플 에 대한One-Time 설정 절차를 수행했는지 확인합니다.
메시지를 로깅하기 위한 C:\LOGS 디렉터리를 만듭니다. 사용자에게 이 디렉터리에 대한 네트워크 서비스 쓰기 권한을 부여합니다.
솔루션의 C# 또는 Visual Basic .NET 버전을 빌드하려면 Windows Communication Foundation 샘플빌드의 지침을 따릅니다.
단일 또는 컴퓨터 간 구성에서 샘플을 실행하려면 Windows Communication Foundation 샘플실행의 지침을 따릅니다.