SoapDocumentMethodAttribute.RequestElementName 屬性

定義

取得或設定與 SOAP 請求相關的 XML 元素,用於 XML Web 服務方法,該元素在服務描述中定義為操作。

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

屬性值

與 SOAP 請求相關的 XML 元素,該請求用於 XML Web 服務方法,該請求在服務描述中定義為操作。 預設值為 XML Web 服務方法的名稱。

範例

以下程式碼範例將 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了當 為 Wrapped時,用來將參數包裹在 SOAP 請求ParameterStyle元素下方Body的 XML 元素。 這反映在 XSD 架構中,該結構在 XML Web 服務的服務描述中,代表對 XML Web 服務方法的 SOAP 請求。

適用於