Share via


SoapDocumentMethodAttribute.RequestElementName 屬性

定義

取得或設定 XML Web Service 方法與 SOAP 要求關聯的 XML 項目,這是定義於服務描述來當做一個作業。

public:
 property System::String ^ RequestElementName { System::String ^ get(); void set(System::String ^ value); };
public string RequestElementName { get; set; }
member this.RequestElementName : string with get, set
Public Property RequestElementName As String

屬性值

String

XML Web Service 方法與 SOAP 要求關聯的 XML 項目,這是定義於服務描述來當做一個作業。 預設值為 XML Web Service 方法的名稱。

範例

下列程式碼範例會將 SOAP 要求中與 XML Web 服務方法相關聯的 XML 專案名稱設定為 MyCustomElement

<%@ WebService Language="C#" Class="SoapDocumentMethodSample" %>
    
using System.Web.Services;
using System.Web.Services.Protocols;

public class SoapDocumentMethodSample
{
   [WebMethod]
   [SoapDocumentMethod(RequestNamespace="http://www.contoso.com",RequestElementName="MyCustomElement")]
   public int[] RequestDocument(int numentries)
   {
    int[] intarray = new int[numentries];
        for (int i=0;i<numentries;i++)
        {
       intarray[i] = i;
        }
        return intarray;
   }
}
<%@ WebService Language="VB" Class="SoapDocumentMethodSample" %>
    
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class SoapDocumentMethodSample

   <WebMethod(),SoapDocumentMethod(RequestNamespace :="http://www.contoso.com",RequestElementName := "MyCustomRequestElement")> _
   Public Function  RequestDocument(numentries as Integer) As Integer()
    Dim intarray(numentries - 1) as Integer
        Dim i as Integer
        For i = 0 To numentries - 1
           intarray(i) = i
        Next
        Return intarray
   End Function
End Class

備註

RequestElementName會定義 XML 專案,當 為 WrappedParameterStyle ,用來將參數包裝在 SOAP 要求的 元素下方 Body 。 這反映在 XSD 架構中,此架構代表 XML Web 服務之服務描述內 XML Web 服務方法的 SOAP 要求。

適用於