방법: 전체 웹 서비스에 대한 기본 SOAP 형식 수정

이 항목은 레거시 기술과 관련된 것입니다. 이제 XML Web services와 XML Web services 클라이언트는 다음을 사용하여 만들어야 합니다. Windows Communication Foundation.

이 절차에서는 전체 웹 서비스에 대한 기본 SOAP 형식을 수정하는 방법에 대해 설명합니다.

웹 서비스에 대한 기본 메서드 형식 스타일을 설정하려면

  1. 웹 서비스를 구현하는 클래스에 SoapRpcService 특성 또는 SoapDocumentService 특성을 적용합니다.

    다음 코드 예제에서는 메서드 형식 스타일을 Document로 설정하고, 기본 매개 변수 형식을 Literal로 설정하며, 단일 요소 내에서 매개 변수를 캡슐화하도록 지정합니다.

    <%@ WebService Language="C#" Class="SoapDocumentServiceSample" %>
     using System.Web.Services;
     using System.Web.Services.Protocols;
     using System.Web.Services.Description;
    
    [SoapDocumentService(Use=SoapBindingUse.Literal,
                         ParameterStyle=SoapParameterStyle.Wrapped)]
    [WebService(Namespace="https://www.contoso.com")]
    public class SoapDocumentServiceSample  
    {
        [ WebMethod ]
        public string UseDefaultEncoding(Address MyAddress, 
                                         bool useZipPlus4) 
        {
         return "Use the default encodings for this Web service.";
        }
    }
    
    <%@ WebService Language="VB" Class="SoapDocumentServiceSample" %>
    Imports System.Web.Services
    Imports System.Xml.Serialization
    Imports System.Web.Services.Protocols
    Imports System.Web.Services.Description
    
    < SoapDocumentService(Use := SoapBindingUse.Literal, _
                          ParameterStyle := SoapParameterStyle.Wrapped)> _
    Public Class SoapDocumentServiceSample
      < WebMethod > _
      Public Function UseDefaultEncoding(MyAddress as Address, _
                                         useZipPlus4 As Boolean) As String 
         Return "Use the default formattings for this Web service."
      End Function
    End Class 
    

    UseDefaultEncoding 웹 서비스 메서드에서 기대하는 SOAP 요청의 XML 부분은 다음과 같습니다.

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <UseDefaultEncoding xmlns="https://www.contoso.com">
          <MyAddress>
            <Street>string</Street>
            <City>string</City>
            <Zip>string</Zip>
          </MyAddress>
          <useZipPlus4>boolean</useZipPlus4>
        </UseDefaultEncoding>
      </soap:Body>
    </soap:Envelope>
    

참고 항목

참조

SoapDocumentServiceAttribute
SoapRpcServiceAttribute

기타 리소스

SOAP 메시지 서식 사용자 지정